I have a .tex
file that I need to compile to PDF using XeLaTeX (I am using fontspec, among other packages). Using RStudio, I can successfully generate a PDF via the Compile PDF command, having specified XeLaTeX as the engine in my RStudio preferences.
How can I programmatically invoke this compilation from a script? I've investigated tools::texi2pdf()
, but when running it on my file I get an error saying The fontspec package requires either XeTeX or LuaTeX
, and I don't see a way of specifying that I want to use XeLaTeX instead of plain LaTeX.
My solution for now is to do a call to system()
. For instance:
system("xelatex --shell-escape my-script.tex")
If there are better solutions that don't require a system()
call (I've heard of issues with cross-platform compatibility), that would be great.