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')