0

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.

hangler
  • 390
  • 3
  • 10

2 Answers2

1

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.

hangler
  • 390
  • 3
  • 10
0

I eventually ended up with the following solution:

install.packages("tinytex")   
require("tinytex")}
install_tinytex(force = TRUE)
tlmgr_install('montserrat') 
xelatex('Report.tex')

This code install TinyTex, then it installs the font package montserrat with tlmgr_install function.

Stepan S. Sushko
  • 1,250
  • 1
  • 9
  • 5