Accent in knitr

女生的网名这么多〃 提交于 2019-12-11 07:54:41

问题


I'm using knitr to compile a PDF file. I have an issue when using accent (Portuguese) such as "é". I've found other users asking similar questions but in that case, there was an error. I was able to compile the pdf (without any error). However, in the pdf file accent words disappear. For example, "número" (number in English) appears in the pdf as "nmero".

I appreciate any guidance.

Thanks. Thiago.

R version 2.15.3 (2013-03-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252 
[2] LC_CTYPE=Portuguese_Brazil.1252   
[3] LC_MONETARY=Portuguese_Brazil.1252
[4] LC_NUMERIC=C                      
[5] LC_TIME=Portuguese_Brazil.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] knitr_1.3.3

loaded via a namespace (and not attached):
[1] digest_0.6.3   evaluate_0.4.5 formatR_0.9    stringr_0.6.2 
[5] tools_2.15.3  

回答1:


You did not provide a minimal reproducible example, so I have to guess from experience: you probably did not specify the input encoding in LaTeX. Depending on the encoding you use, you may want \usepackage[latin9]{inputenc} in your preamble, e.g.

\documentclass{article}
\usepackage[latin9]{inputenc}
\begin{document}
<<>>=
"número"
@
\end{document}

If you use UTF-8, you need \usepackage[utf8]{inputenc}, and so on.



来源:https://stackoverflow.com/questions/18146409/accent-in-knitr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!