2

I would like to include R results in a LuaLaTeX document, which I prefer over XeLaTeX mainly because of the greater support of the package microtype. Do you know whether and how is it possible?

Moreover, for more structured documents, I like to call the chapters' .tex files with the command \input in a master file, which is then compiled. Therefore, I would also like to know, in case you have a solution to the first problem, if it allows such tree structure.

I am especially interested in solutions that refer to Sweave files compilation.

oibaFox
  • 163

2 Answers2

2

There's an option to change the LaTeX engine with R Markdown:

https://rmarkdown.rstudio.com/pdf_document_format.html#latex_engine

Andrew Dunning
  • 1,714
  • 13
  • 21
  • that is definetely interesting to compile Rmarkdown files, however I am interested in compiling Sweave files - I will update the question text. – oibaFox Feb 10 '18 at 15:16
2

The following works in RStudio, the front-end I use for R programming:

First I created a .Renviron file containing the following line:

RSTUDIO_PDFLATEX="lualatex"

This sets the RStudio environment variable to for the TeX engine.

This file is normally in your home folder, i.e., ~/.Renviron

Then the default engine that knitr (and Sweave, I assume) will use will be LuaLaTeX.

Note that you cannot use the % !TeX program = LuaLaTeX directive since this line is parsed by RStudio, and it only recognizes pdfLaTeX and XeLaTeX as valid engines. These engines, however, will still work on a per-file basis using % !TeX program = pdfLaTeX or % !TeX program = XeLaTeX.

As to your second question, yes, your .Rnw file behaves just like any LaTeX document, and \input and similar commands are possible.

Yihui Xie
  • 2,805
Alan Munn
  • 218,180