I'm using RStudio 0.98.1102 on Windows 7 with knitr 1.10 (R 3.1.2) and tried to knit the following file:



ä ö ü Ä Ö Ü ß

options(encoding = "UTF-8")


which results in an "Package inputenc Error: Unicode char.. not set up for use with LaTeX" when running pdflatex over the resulting .tex file.

resulting pdf with option call

When I try knitting without the options() call, everything works.

resulting pdf without option call

I expected a behaviour the other way round and would appreciate an explanation.

  • It looks as if with the option, knitr (or whatever is using the option) assumes that the start document is 8-bit encoded and converts it to utf8. – Ulrike Fischer Mar 6 '15 at 12:54
  • Please do not use options(encoding = ...) unless you really understand what it means. In most cases, it is just the wrong thing to do (especially on Windows, of which the native encoding is not UTF-8). – Yihui Xie Mar 6 '15 at 14:26

Your Answer

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

Browse other questions tagged or ask your own question.