# 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.
# 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).
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".
# Set the PREVIEW_CONTINUOUSLY variable to -pvc to switch latexmk into the preview continuously mode.
.PHONY: clean cleanall
# -bibtex also removes the .bbl files (http://tex.stackexchange.com/a/83384/79184).
latexmk -c -bibtex *.tex
latexmk -C -bibtex *.tex
If there is an error while running 'make' command which prompts the following,