Makefile for LaTeX

# The first rule in a Makefile is the one executed by default ("make"). It should always be the "all" rule, so that "make" and "make all" are identical.
all: *.pdf

# MAIN LATEXMK RULE:-
# pdf tells latexmk to generate a PDF instead of DVI.
# pdflatex="" tells latexmk to call a specific backend with specific options.
# use-make tells latexmk to call make for generating missing files.
# interaction=nonstopmode keeps the pdflatex backend from stopping at missing file reference and interactively asking you for an alternative.
# synctex=1 is required to jump between the source PDF and the text editor.
# pvc (preview continuously) watches the directory for changes.
# quiet suppresses most status messages (https://tex.stackexchange.com/questions/40783/can-i-make-latexmk-quieter).
.PRECIOUS: *.pdf
*.pdf: *.tex
	latexmk -quiet -bibtex $(PREVIEW_CONTINUOUSLY) -f -pdf -pdflatex="xelatex -file-line-error -synctex=1 -interaction=nonstopmode -shell-escape %S %O -verbose" -use-make *.tex

# The .PHONY rule keeps make from processing a file named "watch" or "clean".
.PHONY: watch

# Set the PREVIEW_CONTINUOUSLY variable to -pvc to switch latexmk into the preview continuously mode.
watch: PREVIEW_CONTINUOUSLY=-pvc
watch: *.pdf

.PHONY: clean cleanall

# -bibtex also removes the .bbl files (http://tex.stackexchange.com/a/83384/79184).
clean:
	latexmk -c -bibtex *.tex

cleanall:
	latexmk -C -bibtex *.tex

Additional Info

If there is an error while running 'make' command which prompts the following,
:makefile:4: *** missing separator. Stop.
check out [this solution] with funny remarks given by nsd:
cat -e -t -v

Rujukan:


Kali terakhir halaman ini dikemaskini/disemak semula adalah pada .
Top