Created
May 16, 2016 14:44
-
-
Save alexjohnj/35fa1617ed6a21fe11f126fb906d6001 to your computer and use it in GitHub Desktop.
A generic Makefile template for somewhat complicated LaTeX documents.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a generic Makefile that can be used to compile somewhat complicated | |
| # LaTeX documents. It assumes a directory structure like this | |
| # . | |
| # ├── figures/*.{pdf,tex} | |
| # ├── MAIN.tex | |
| # ├── Makefile | |
| # ├── Preamble.tex | |
| # ├── sections/*.tex | |
| # └── latex.out/ | |
| # and that you want to use a LaTeX runner such as latexrun or latexmk. The | |
| # Makefile's configured for latexrun but it should be easy to switch to | |
| # something else by customising the variables $(LATEXRUN) and $(LATEXRUN_OPTS). | |
| # | |
| # The watch task uses [watchman](https://github.com/facebook/watchman) to watch | |
| # all the files defined in the variables $(MAIN), $(BIB_FILE), $(FIGURES), | |
| # $(PREAMBLE), $(SECTIONS) and $(OTHER_FILES) running the all task if any of | |
| # them changes. | |
| # Main TeX file WITHOUT extension | |
| MAIN = | |
| PREAMBLE = Preamble.tex | |
| # No references? Just assign this to nothing. | |
| BIB_FILE = | |
| TMP_DIR = latex.out | |
| FIGURE_DIR = figures | |
| SECTIONS_DIR = sections | |
| FIGURES = $(wildcard $(FIGURE_DIR)/*.tex $(FIGURE_DIR)/*.pdf) | |
| SECTIONS = $(wildcard $(SECTIONS_DIR)/*.tex) | |
| # Define any other files (e.g., BibLaTeX configuration files) here. | |
| OTHER_FILES = | |
| LATEX = lualatex | |
| LATEX_OPTS = --interaction=nonstopmode --shell-escape | |
| LATEXRUN = latexrun | |
| LATEXRUN_OPTS = --latex-cmd=$(LATEX) --latex-args="$(LATEX_OPTS)" --bibtex-cmd=biber -O=$(TMP_DIR) | |
| .PHONY: FORCE | |
| $(MAIN).pdf: FORCE $(MAIN).tex $(FIGURES) $(SECTIONS) $(BIB_FILE) $(OTHER_FILES) | |
| $(LATEXRUN) $(LATEXRUN_OPTS) $(MAIN).tex | |
| .PHONY: clean | |
| clean: | |
| $(LATEXRUN) --clean-all | |
| .PHONY: all | |
| all: $(MAIN).pdf | |
| .PHONY: watch | |
| watch: | |
| watchman-make -p $(MAIN).tex $(PREAMBLE) $(FIGURES) $(SECTIONS) $(BIB_FILE) $(OTHER_FILES) -t all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works really well for me. Thanks for sharing it. 😊