Skip to content

Latest commit

 

History

History
39 lines (19 loc) · 2.86 KB

README.md

File metadata and controls

39 lines (19 loc) · 2.86 KB

A Makefile for LaTeX Documents

This is a makefile for LaTeX documents which seeks to provide a general purpose, easily extendable tool for compiling documents.

Motivation

There are a couple of popular makefiles for LaTeX in existence (1, 2); feel free to search yourself and you'll find many more of various quality. Its been my impression that these makefiles are constructed with the goal of providing a holistic and singularly complete experience. That is, this is the one and only makefile you will ever need for your LaTeX documents. The result of this motivation is, predictably, complexity.

Here I take an alternative approach. Here we seek to provide the cleanest approach to compiling documents which fall under a vast majority of possible use cases. Beyond that, the makefile should be amenable to alteration so that an author can quickly digest and alter the makefile to account for whatever workflow they need for that particular document.

Usage

The makefile makes only the following assumptions about the structure of your project:

  1. the obj/ directory is not to be used. The auxiliary files generated by latex, bibtex, and other tools will be redirected to this folder. Generated DVI, PS, and PDF files will also be placed in this directory, and

  2. any files on which you want to condition recompilation must exist in the directory structure rooted at the directory in which the makefile exists.

Place a copy of the makefile in the root directory of your project. Feel free to rename the file to suit your needs; if you rename it to be "Makefile" or "makefile" so that it will automatically be recognized by make. Alternatively you are free to use make with the -f or --file flags to specify latex.makefile as your makefile.

Next we must specify the name of the main .tex file. This will serve as the project name for the purposes of compilation. Let consider a hypothetical resume document which uses resume.tex as the primary .tex file. At the beginning of the makefile you would add the line

PROJECT = resume

informing the makefile to use resume.tex when compiling the document and will then generate obj/resume.dvi, obj/resume.ps, and obj/resume.pdf.

There are three primary targets defined.

  • default: Compiles the document and converts the result to a PDF file.

  • display: Displays the compiled document in a standard PDF viewer. Linux uses Evince and Mac OSX uses the system specified default (likely Preview).

  • clean: The quintessential target. Removes the obj/ folder and thus removes and generated files.

Customization

The options for each program are defined using environment variables which are aptly named. By default the flags are constructed to favor graphical quality over file size (going far beyond the reasonable, some might say).