2

When compiling pdf documents with complex tikz figures using knitr, the pdftex engine would sometimes run out of memory. Thus, I used the luatex engine to compile these Rnw files. However, I am not able to include Umlauts (äüö) in my plots this way. Please see the example:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\begin{document}
<<pdftexGood, dev="tikz", message=FALSE, echo=FALSE, cache=FALSE>>=
options(tikzDefaultEngine = "pdftex")
plot(rnorm(100), xlab="Der satanarchäolügenialkohöllische Wunschpunsch")
@
<<luatexBad, dev="tikz", message=FALSE, echo=FALSE, cache=FALSE, eval=FALSE>>=
options(tikzDefaultEngine = "luatex")
plot(rnorm(100), xlab="Der satanarchäolügenialkohöllische Wunschpunsch")
@
\end{document}

When changing eval=TRUE in the luatex chunk, I get an "Error in getMetricsFromLatex(TeXMetrics)".

What can I do to resolve the issue? Thanks!

  • 3
    Load the fontspec package and remove inputenc when using luatex (but I don't know if this related to your problem). – Ulrike Fischer Apr 26 '15 at 13:19
  • Thanks @ulrike, this pointed me to the right direction and was able to resolve the issue. I'll write up an answer to myself. – UncertainVagery Apr 26 '15 at 13:31
0

Thanks to Ulrike Fischer's comment, I was able to resolve the issue myself. Using RStudio as an editor, it turns out that the Rnw file was still compiled using pdftex. Thus, the luatex-chunk needed a different package to be used compared to the pdftex-document (inputenc vs fontspec).

As I was not able to set luatex as a compiler in RStudio, I used XeLaTex and adapted the packages. Now, I can compile the luatex-chunk just fine. The fact that the pdftex-chunk won't compile anymore (for the above mentioned package problems) is no problem for me.

% !TeX program = XeLaTeX
\documentclass{article}
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\begin{document}
<<pdftexBad, dev="tikz", message=FALSE, echo=FALSE, cache=FALSE>>=
#options(tikzDefaultEngine = "pdftex")
#plot(rnorm(100), xlab="Der satanarchäolügenialkohöllische Wunschpunsch")
@
<<luatexGood, dev="tikz", message=FALSE, echo=FALSE, cache=FALSE, eval=TRUE>>=
options(tikzDefaultEngine = "luatex")
plot(rnorm(100), xlab="Der satanarchäolügenialkohöllische Wunschpunsch")
@
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.