Linux command
latexmk 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Compile a LaTeX document
latexmk -pdf [document.tex]
Compile and continuously watch
latexmk -pdf -pvc [document.tex]
Compile using XeLaTeX
latexmk -xelatex [document.tex]
Compile using LuaLaTeX
latexmk -lualatex [document.tex]
Clean auxiliary files
latexmk -c [document.tex]
Clean all generated files
latexmk -C [document.tex]
Compile with shell escape
latexmk -pdf -shell-escape [document.tex]
Silent mode
latexmk -pdf -silent [document.tex]
说明
latexmk is a Perl script that automates LaTeX document compilation. It determines the correct sequence and number of runs needed, automatically running latex, bibtex/biber, makeindex, and other tools as required. LaTeX documents often need multiple passes: cross-references, bibliographies, and indexes require running latex/bibtex repeatedly. Latexmk analyzes log files and auxiliary files to determine when recompilation is needed and in what order. The preview continuously mode (-pvc) watches source files and recompiles on changes. Combined with a PDF viewer that auto-refreshes (like Zathura, Skim, or SumatraPDF), this provides a live preview workflow. Configuration can be set in latexmkrc files (system-wide, user, or project-specific). Common settings include default options, custom rules for specialized processing, and viewer preferences. For complex documents with custom build steps, latexmk supports custom dependency rules and processing scripts, making it adaptable to most LaTeX workflows.
参数
- Generate PDF via pdflatex.
- -xelatex
- Generate PDF via xelatex.
- -lualatex
- Generate PDF via lualatex.
- -dvi
- Generate DVI file.
- -ps
- Generate PostScript file.
- -pvc
- Preview continuously (watch mode).
- -pv
- Preview after compilation.
- -c
- Clean up auxiliary files.
- -C
- Clean up all generated files including output.
- -f
- Force processing past errors.
- -g
- Force full processing (ignore timestamps).
- -silent
- Reduce output verbosity.
- -verbose
- Increase output verbosity.
- -interaction=_mode_
- Set interaction mode: nonstopmode, batchmode, errorstopmode, scrollmode.
- -shell-escape
- Enable shell escape (for packages like minted).
- -outdir=_dir_, -output-directory=_dir_
- Output directory for generated files.
- -auxdir=_dir_
- Directory for auxiliary files.
- -jobname=_name_
- Set output base name.
- -bibtex, -nobibtex
- Force or disable running bibtex/biber.
- -recorder
- Enable recorder to track file dependencies.
- -norc
- Skip reading initialization (rc) files.
- -deps
- Show a list of dependent files (Make-compatible format).
- -diagnostics
- Print detailed diagnostics.
FAQ
What is the latexmk command used for?
latexmk is a Perl script that automates LaTeX document compilation. It determines the correct sequence and number of runs needed, automatically running latex, bibtex/biber, makeindex, and other tools as required. LaTeX documents often need multiple passes: cross-references, bibliographies, and indexes require running latex/bibtex repeatedly. Latexmk analyzes log files and auxiliary files to determine when recompilation is needed and in what order. The preview continuously mode (-pvc) watches source files and recompiles on changes. Combined with a PDF viewer that auto-refreshes (like Zathura, Skim, or SumatraPDF), this provides a live preview workflow. Configuration can be set in latexmkrc files (system-wide, user, or project-specific). Common settings include default options, custom rules for specialized processing, and viewer preferences. For complex documents with custom build steps, latexmk supports custom dependency rules and processing scripts, making it adaptable to most LaTeX workflows.
How do I run a basic latexmk example?
Run `latexmk -pdf [document.tex]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -pdf do in latexmk?
Generate PDF via pdflatex.