The function latexmk()
emulates the system command latexmk
(https://ctan.org/pkg/latexmk) to compile a LaTeX document to PDF. The
functions pdflatex()
, xelatex()
, and lualatex()
are
wrappers of latexmk(engine =, emulation = TRUE)
.
latexmk(file, engine = c("pdflatex", "xelatex", "lualatex"), bib_engine = c("bibtex",
"biber"), engine_args = NULL, emulation = TRUE, max_times = 10,
install_packages = emulation && tlmgr_available())pdflatex(...)
xelatex(...)
lualatex(...)
A LaTeX file path.
A LaTeX engine (can be set in the global option
tinytex.engine
, e.g., options(tinytex.engine = 'xelatex')
).
A bibliography engine (can be set in the global option
tinytex.bib_engine
).
Command-line arguments to be passed to engine
(can
be set in the global option tinytex.engine_args
, e.g.,
options(tinytex.engine_args = '-shell-escape'
).
Whether to emulate the executable latexmk
using R.
The maximum number of times to rerun the LaTeX engine when
using emulation. You can set the global option
tinytex.compile.max_times
, e.g.,
options(tinytex.compile.max_times = 3)
.
Whether to automatically install missing LaTeX
packages found by parse_packages()
from the LaTeX log. This
argument is only for the emulation mode and TeX Live.
Arguments to be passed to latexmk()
(other than
engine
and emulation
).
The latexmk
emulation works like this: run the LaTeX engine once
(e.g., pdflatex
), run makeindex
to make the index if
necessary (the *.idx
file exists), run the bibliography engine
bibtex
or biber
to make the bibliography if necessary
(the *.aux
or *.bcf
file exists), and finally run the LaTeX
engine a number of times (the maximum is 10 by default) to resolve all
cross-references.
If emulation = FALSE
, you need to make sure the executable
latexmk
is available in your system, otherwise latexmk()
will fall back to emulation = TRUE
. You can set the global option
options(tinytex.latexmk.emulation = FALSE)
to always avoid emulation
(i.e., always use the executable latexmk
).