tikzDevice and knitr

Unlike knit2pdf(), the function knit() does not compile the Rnw source file with latex to a PDF document.

knit2pdf() takes an argument for which latex enginge to use, eg compiler='xelatex', but knit() does not.

But if you use the device tikz to generate your inline graphs in the knitr document, and the knitr document relies on latex packages which in turn is incompatible with pdflatex, then you will get trouble, unless you somehow instructs knit() to use xelatex rather than pdflatex.

To solve the problem, use a .Rprofile file in the current directory with the following content:

options(tikzDefaultEngine = 'xetex')

comments powered by Disqus


Back to the index

Blog roll

R-bloggers, Debian Weekly
Valid XHTML 1.0 Strict [Valid RSS] Valid CSS! Emacs Muse Last modified: oktober 12, 2017