A Makefile for LaTeX/Prosper

The sequence of commands for processing a LaTeX file into a PDF file were described in the section Compiling slides into PDF. Although these commands can be typed and executed manually, their repeated use during a write/test/debug cycle can be tiresome and error-prone.

In my writing and programming projects I use Makefiles to organize and automate the flow of work. A Makefile contains a sequence of instructions to be performed. The UNIX utility, make, reads and executes instructions specified in a Makefile.

The description of the make utility is outside of the scope of this tutorial so I will not get into that. However, you don't need to be a make expert in order to use it.

I suggest that you download the Makefile pointed to by this link and modify it for your own use. (Note that on some browsers you will have to right-click on a link to download it.) The contents of that file are shown below.

Important! Beware that the layout of a Makefile follows certain very precise rules. Cutting and pasting by mouse almost certainly will destroy that precise layout. Don't cut and paste. Download it as instructed in the the previous paragraph.

# Generic make file for LaTeX: requires GNU make

TEXFILE	= slides.tex

.PHONY: dvi ps pdf clean

pdf:	$(TEXFILE:.tex=.pdf)
ps:	$(TEXFILE:.tex=.ps)
dvi:	$(TEXFILE:.tex=.dvi)

%.dvi: %.tex
	( \
	latex $<; \
	while grep -q "Rerun to get cross-references right." $(<:.tex=.log); \
	do \
		latex $<; \
	done \
	)

%.ps: %.dvi
	dvips -q -t a4 $< -o $(<:.dvi=.ps)

%.pdf: %.ps
	ps2pdf -dPDFSETTINGS=/prepress $<

clean:
	@rm -f \
	$(TEXFILE:.tex=.aux) \
	$(TEXFILE:.tex=.log) \
	$(TEXFILE:.tex=.out) \
	$(TEXFILE:.tex=.dvi) \
	$(TEXFILE:.tex=.pdf) \
	$(TEXFILE:.tex=.ps)

In normal use, you will edit the Makefile's "TEXFILE = slides.tex" line and replace "slides.tex" by the name of your LaTeX file. No other changes should be necessary.

Then the single command "make" will process your LaTeX file and produce a PDF file. That's all!

Remark 1: The command "make" takes your file through the following sequence:
file.tex --> file.dvi --> file.ps --> file.pdf

The command "make dvi" will run only the first step, i.e.,

file.tex --> file.dvi

This is useful for debugging your LaTeX source file.

The command "make ps" will run only the first and second steps, i.e.,

file.tex --> file.dvi --> file.ps

This is useful for creating files for viewing with ghostview, as in:

gv -landscape file.ps

The command "make clean" will delete all the files created by make. This is useful for removing clutter from your directory.

Remark 2: In the Makefile shown above, I have made essential use of extensions available in GNU make; it will not work with the classic UNIX make. Since GNU make is commonly available on all platforms, I don't consider this a serious drawback.
Remark 3: You may use the Makefile above for other LaTeX projects -- to write your thesis, for instance -- not necessarily for Prosper presentations only. If your document is expected to be printed on an 8.5"x11" paper, then be sure to delete the "-t a4" flag from the Makefile, that is, change the line containing the dvips command to:

	dvips -q $< -o $(<:.dvi=.ps)