I want to print some foreign characters in my final PDF produced with RStudio (0.99) + *.Rnw-File with knitr + XeLaTex (via Miktex).
While using XeLaTex and polyglossia I can manage that all foreign characters are print properly in the PDF, if I pass it directly to the Tex-environment of the *.Rnw-File.
If I use the Cat("...")-function to print text in the PDF within a R-chunk, it fails in some characters ("1."), in others not ("2....").
I use utf8 enconding in the RStudio settings which obviously works well inside Tex-environment. But why does the cat-expression inside the R-chunk dont like the same characters?
What can I do to use cat("...") expression (I frequently used) also for the foreign characters?
MWE:
\documentclass[utf8, a4paper]{article} % with/without [utf8] does not change anything
% !Rnw weave = knitr
% !TeX program = XeLaTeX
\usepackage{polyglossia}
\setmainlanguage[]{english}
\usepackage{fontspec}
\begin{document}
Directly passed in tex environment:
1. äöüßĐØ
2. ČĈĐĎŸ
<<echo=FALSE, results = 'asis'>>=
cat("Within a R-Knitr-Junk: \\newline")
cat("1. äöüßĐØ ~")
cat("2. ČĈĐĎŸ")
@
\end{document}
PDF-Result:
Checking the tex-file produced by RSTudio (using Notepad++ with utf8 support) the line inside the R-chunk looks like:
OS: Win7/64Bit, RStudio 0.99 , R 3.2.5, MikTex 2.9.5900


catfunction, not about TeX. – Thruston Apr 26 '17 at 07:28