LaTeX-Mk Examples

Simple Project

Consider a simple document which is completely contained in one LaTeX file. To produce a postscript file for printing and a PDF file you might use the following sequence of commands:
latex mydoc.tex
latex mydoc.tex
latex mydoc.tex
dvips -Ppdf -j0 -o mydoc.ps mydoc.dvi
ps2pdf mydoc.ps mydoc.pdf

The triple invocation of latex is to ensure that all references have been properly resolved and any page layout changes due to inserting the references have been accounted for. The sequence of commands isn't horrible, but it still is several commands and one of them, dvips, has some flags to remember. To use LaTeX-Mk for this project, you would create a file called Makefile that contains the following.

NAME=mydoc

include /usr/local/share/latex-mk/latex.gmk
Note that the "include /usr/local/share/latex-mk/latex.gmk" is the syntax for GNU make. If you are using BSD make you would replace the include line with ".include "/usr/local/share/latex-mk/latex.mk"". In both examples, you would replace /usr/local with the installation prefix on your system. For the remainder of this document we will use the BSD style of include in the examples. Now to create a PDF file you simply run "make pdf". For larger projects which may need to run programs to export drawings to postscript files for inclusion or run BibTeX to generate bibliographies, the generation of PDF (or other) files becomes increasingly complicated to run manually. With LaTeX-Mk, such operations are still very simple.

A More Complicated Example

As a more complicated example, consider a project whose LaTeX input is broken apart in to many .tex files. Also suppose the project includes a bibliography and a large number of figures created with the Tgif program. An example Makefile for this project might look like:
NAME= mydoc
TEXSRCS= ch1.tex ch2.tex ch3.tex refs.tex
BIBTEXSRCS= mybib.bib
TGIFDIRS= tgif_figs

.include "/usr/local/share/latex-mk/latex.mk"

In this example is it assumed that all of the Tgif figures reside in a subdirectory called tgif_figs. When the user issues a make command, all of the steps required to reformat the document are taken. Because of the dependency structure imposed by make, only the steps which need to be taken are done. This avoids re-exporting a large number of figures which may have not changed, but ensures that files which need processing are processed. Also, the user only needs to remember one simple command.

A Multiple Document Example

For the final example, consider a project that produces several different documents. These documents share some common input files, a copyright section and an author biography section, but also have some unique inputs (otherwise they would be the same document). Also suppose the project includes a large number of figures created with the Xfig program. In addition, some of the figures are common to both documents and some are not. An example Makefile for this project might look like:
NAME= mydoc otherdoc
TEXSRCS= copyright.tex authorinfo.tex
mydoc_TEXSRCS= ch1.tex ch2.tex ch3.tex refs.tex
otherdoc_TEXSRCS= ch1a.tex ch2a.tex
XFIGDIRS= common_xfig
mydoc_XFIGDIRS= mydoc_xfig
otherdoc_XFIGDIRS= other_xfig

.include "/usr/local/share/latex-mk/latex.mk"

In this example is it assumed that all of the common Xfig figures reside in a subdirectory called common_xfig, the Xfig figures specific to mydoc reside in a subdirectory called mydoc_xfig and the Xfig figures specific to otherdoc reside in a subdirectory called other_xfig. When the user issues a make command, all of the steps required to reformat the document are taken. Because of the dependency structure imposed by make, only the steps which need to be taken are done. This avoids re-exporting a large number of figures which may have not changed, but ensures that files which need processing are processed.

[LaTeX-Mk Logo]

Information
 Bug Reports
 Examples
 F.A.Q.
 Home
 History
 Manual
 Obtaining
 Sourceforge
   Project Page

SourceForge Logo
 
Copyright © 2002, 2003, 2004, 2005, 2006, 2007 Dan McMahill ALL RIGHTS RESERVED.