This is a GNU Makefile for typesetting LaTeX2e documents. Expected to work with
TeX Live 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
) distributed under the MIT License. Just put it into your directory. - Automatic detection of LaTeX source files. Just type
make
and then the Makefile knows what to do. - Dependency tracking.
- Handling BibTeX, MakeIndex, glossaries and axodraw2.
- Partial support for biber, bib2gls and sortref.
- Colorized output.
- Highly customizable by optional user configuration files (
latex.mk
files). - Placing intermediate files into a directory (
BUILDDIR
variable). - Latexdiff between Git revisions (
DIFF
variable). - Running code prettifiers (
make pretty
). latexindent has built-in support. - Linting (
make lint
). ChkTeX, GNU Aspell, Hunspell, textlint and RedPen have built-in support. - Creating tar-gzipped source files for arXiv
submission (
make dist
). - Watching source files to automatically typeset documents when they are modified (
make watch
).
Download Makefile
via
this link
in your browser or by using curl
:
curl -O https://raw.githubusercontent.com/tueda/makefile4latex/v0.11.1/Makefile
and put it into a directory that contains LaTeX files. Then just type:
make
See also the Wiki page for other ways to start.
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
.pretty
: Run code prettifiers for source files in the current directory.lint
: Run linters for source files in the current directory.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. Given on the command line or in the user configuration 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
.
-
BUILDDIR
: Place intermediate files intoBUILDDIR
. Given on the command line or in the user configuration files. It is assumed that the-output-directory=DIR
option is available in the LaTeX distribution you are using (which is true in TeX Live.) Note that some (La)TeX packages may not follow this option and may generate some files in the working directory, or may not correctly work in the worst case. -
DIFF
: Enable the Git-latexdiff mode. Given on the command line only. 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. -
COLOR
: Control how colors are used in the output. Given on the command line or in the user configuration files.always
: Use colors.never
: Do not use colors.auto
(default): Use colors unless the output is piped.
-
PRETTIFIERS
: List prettifiers to be used bymake pretty
. Given on the command line or in the user configuration files. The default value isPRETTIFIERS = latexindent
, so it runs latexindent. -
LINTS
: List linters to be used bymake lint
. Given on the command line or in the user configuration files. The default value isLINTS = chktex
, so it runs ChkTeX. One can add or overwrite the list, for example,LINTS += aspell
orLINTS = hunspell textlint redpen
. -
NODISTFILES
,EXTRADISTFILES
,ANCILLARYFILES
: Control which files are included in tar-gzipped source files. Given on the command line or in the user configuration files. A tar-gzipped source file,foo.tar.gz
for example, is created from the corresponding source file,foo.tex
, and the dependent files. One can setNODISTFILES
to exclude some of the dependent files from the resultant file. On the other hand,EXTRADISTFILES
represents additional files to be included. The00README.XXX
file is also examined to determine additionally included files. Moreover, files listed inANCILLARYFILES
are copied to theanc
directory inside the resultant file. -
MOSTLYCLEANFILES
,CLEANFILES
: Specify files to be deleted formake mostlyclean
andmake clean
, respectively. Given on the command line or in the user configuration files. -
PREREQUISITE
,PREREQUISITE_SUBDIRS
,POSTPROCESS
: Specify prerequisite and postprocessing tasks for documents in the current directory. Given on the command line or in the user configuration files.PREREQUISITE
is a list of targets to be built before building documents in the current directory.PREREQUISITE_SUBDIRS
is a list of targets in all the subdirectories required to build documents in the current directory.POSTPROCESS
is a list of targets to be built after the completion of the building documents in the current directory.
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.