编织()在Windows上调用以下文档 dia.Rnw 时,只会打印块(块)中的变音字符 . 使用 \Sexpr{} 内联打印它们按预期工作 .

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}

\begin{document}

<<c1>>=
sCaron <-  "\u0161"
@

Priting the diacritic character \Sexpr{sCaron} inline with \verb|Sexpr{sCaron}| results in 
the correct UTF-8 character in the .tex document.

Using a chunk/block (output is wrapped in a verbatim environment) does not print the right 
character.
<<c2>>=
sCaron
@


\end{document}

该文件保存为UTF-8,调用knitr(版本1.11)

knit("dia.Rnw", encoding = "UTF-8")

我的 sessionInfo()

R version 3.2.2 (2015-08-14)

Platform: x86_64-w64-mingw32 / x64(64位)

Running under: Windows 7 x64(内部版本7601)Service Pack 1

locale: LC_COLLATE = German_Austria.1252,LC_CTYPE = German_Austria.1252,LC_MONETARY = German_Austria.1252,LC_NUMERIC = C,LC_TIME = German_Austria.1252

attached base packages: stats,graphics,grDevices,utils,datasets,methods,base

other attached packages: knitr_1.11,devtools_1.9.1.9000

loaded via a namespace (and not attached): magrittr_1.5,formatR_1.2.1,tools_3.2.2,memoise_0.2.1,stringi_0.5-5,highr_0.5.1,stringr_1.0.0,digest_0.6.8,evaluation_0.8,fortunes_1.5-2