A Simple Makefile for Latex

By Zhiqiang Ma On Mar 22, 2013

Compiling a latex documents may take several steps when bibtex is used with latex. However, this latex compilation process is the same for most documents. We can make it a template with Makefile so that simply running make will generate the dvi/ps/pdf files for us.

A simple Makefile for using latex with bibtex enabled is as follows (replace the spaces with TAB at the beginning of each line).

Download the Makefile directly: Makefile.

filename=paperfilename

pdf: ps
 ps2pdf -dPDFSETTINGS=/printer ${filename}.ps

ps: dvi
 dvips ${filename}.dvi

dvi:
 latex ${filename}
 bibtex ${filename} || true
 latex ${filename}
 latex ${filename}

read:
 evince ${filename}.pdf &

aread:
 acroread ${filename}.pdf &

clean:
 rm -f ${filename}.ps ${filename}.pdf ${filename}.log ${filename}.aux ${filename}.out ${filename}.dvi ${filename}.bbl ${filename}.blg

Please replace “paperfilename” with the tex file name.

The Makefile first generates dvi by calling latex by 3 times and bibtex by 1 time and then generate the ps file and pdf files.

The usage:

Compile to pdf:

make

Compile pdf file and read it in Evince:

make clean; make && make read

Or use Adobe Reader by:

make clean; make && make aread

Clean up temporary files:

make clean
By: Zhiqiang Ma Last updated: Mar 22, 2013 Views: 2,407
Tags: , , , , ,

About Zhiqiang Ma

Zhiqiang Ma is a PhD candidate at Dep. of CSE, HKUST. He is interested in system software for cloud computing, virtualization of large-scale distributed system, etc. Find Zhiqiang on Facebook, Twitter, LinkedIn and Google+.

Add your comments, share your thoughts

Be nice. Keep it clean. Stay on topic. No spam.