This is a GNU Makefile for typesetting LaTeX documents. Expected to work with
TeXLive on Linux and similar systems, e.g., on
macOS or Cygwin. Just download a single Makefile
and put it in your directory
containing LaTeX source files. Running make
will generate PDF files for your
documents.
- Only a single file (
Makefile
). - Automatic detection of LaTeX source files. Just type
make
and then the Makefile knows what to do. - Dependency tracking.
- Handling BibTeX, MakeIndex, glossaries, axodraw2 etc.
- Colorized output.
- Can create tar-gzipped source files for arXiv
submission (
make dist
). - Can watch sources and automatically typeset documents (
make watch
).
Download Makefile
by using wget
:
wget https://raw.githubusercontent.com/tueda/makefile4latex/master/Makefile
or curl
:
curl -O https://raw.githubusercontent.com/tueda/makefile4latex/master/Makefile
or via this link in your browser. Put it into a directory that contains LaTeX files. Then just type:
make
all
(default): Build all documents in the current directory.all-recursive
: Build all documents in the source tree.dvi
,ps
,pdf
,eps
,svg
,jpg
,png
: Build all documents with the specified file format in the current directory.help
: Show help message.clean
: Delete all files created by runningmake
.mostlyclean
: Delete only intermediate files created by runningmake
.dist
: Create tar-gzipped archives for arXiv submission.watch
: Watch the changes and automatically rebuild documents in the current directory.upgrade
: Upgrade the setup. For a Git repository, if there is no.gitignore
file, it installs the default.gitignore
. (Be careful not to overwrite any local changes!)
It is also possible to make each target file. For example, make foo.pdf
tries
to generate the pdf file from foo.tex
.
-
TOOLCHAIN
: Control how PDF files are generated from LaTeX files.latex
: Alias tolatex_dvips
.latex_dvips
: Uselatex
-->dvips
-->ps2pdf
.latex_dvipdf
: Uselatex
-->dvipdf
.platex
: Alias toplatex_dvips
.platex_dvips
: Useplatex
-->dvips
-->ps2pdf
.platex_dvipdfmx
: Useplatex
-->dvipdfmx
.uplatex
: Alias touplatex_dvips
.uplatex_dvips
: Useuplatex
-->dvips
-->ps2pdf
.uplatex_dvipdfmx
: Useuplatex
-->dvipdfmx
.pdflatex
(default): Usepdflatex
.xelatex
: Usexelatex
.lualatex
: Uselualatex
.luajitlatex
: Useluajitlatex
.
-
DIFF
: Enable the Git-latexdiff mode. Requireslatexdiff
andlatexpand
. TheDIFF
variable specifies a Git revision for which a latexdiff with the working tree is performed, e.g.,make DIFF=HEAD^
. The resultant document has a postfix-diff
likefoo-diff.pdf
. It is also possible to make a latexdiff between two revisions, e.g.,make DIFF=HEAD~3..HEAD
provided both revisions contain the source file.
The Makefile includes latex.mk
(as well as .latex.mk
) at the very end if
exists. This file can be put in the user's home directory and/or the current
working directory. It can be used for customizing the behaviour of the
Makefile, for example, by setting TOOLCHAIN
. For example, if you want to use
the latex
-> dvips
-> ps2pdf
toolchain instead of the default one
pdflatex
, then run the following command:
echo 'TOOLCHAIN = latex_dvips' >>latex.mk
See also the Wiki page for more customizations.