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
makeand 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.mkfiles). - Placing intermediate files into a directory (
BUILDDIRvariable). - Latexdiff between Git revisions (
DIFFvariable). - 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.13.0/Makefileand put it into a directory that contains LaTeX files. Then just type:
makeSee 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.bundle: Create an archive containing all files from the current Git repository.watch: Watch the changes and automatically rebuild documents in the current directory.upgrade: Upgrade the setup. For a Git repository, if there is no.gitignorefile, 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=DIRoption 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. Requireslatexdiffandlatexpand. TheDIFFvariable 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-difflikefoo-diff.pdf. It is also possible to make a latexdiff between two revisions, e.g.,make DIFF=HEAD~3..HEADprovided 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 += aspellorLINTS = 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.gzfor example, is created from the corresponding source file,foo.tex, and the dependent files. One can setNODISTFILESto exclude some of the dependent files from the resultant file. On the other hand,EXTRADISTFILESrepresents additional files to be included. The00README.XXXfile is also examined to determine additionally included files. Moreover, files listed inANCILLARYFILESare copied to theancdirectory inside the resultant file. -
BUNDLEFILE: Specify the archive filename generated bymake bundle. The valid file extensions are.tar.gz,.tgzand.zip. The default value isbundle.tar.gz. -
MOSTLYCLEANFILES,CLEANFILES: Specify files to be deleted formake mostlycleanandmake 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.PREREQUISITEis a list of targets to be built before building documents in the current directory.PREREQUISITE_SUBDIRSis a list of targets in all the subdirectories required to build documents in the current directory.POSTPROCESSis 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.mkSee also the Wiki page for more customizations.