2

Has someone experience with R packages Knitr and markdown and working with diacritics? Is it possible to write in another language and still have the output in pdf?

The knitr Html converter knit2html won't let me to convert the R markdown document and consequently convert it into pdf with pandoc.

Thomas
  • 43,637
  • 12
  • 109
  • 140
Maximilian
  • 4,177
  • 7
  • 46
  • 85

3 Answers3

2

I had no problem with the following file:

Test rmd with diacritical marks
=============

Hello: Dvořak, müsli, éèô


```{r}
exp(pi)
```

From the command line:

Rscript -e "library('knitr'); knit('tmp.rmd')"
pandoc -o tmp.pdf tmp.md

The key point may be that you need to knit (to convert rmd to md), then run pandoc: don't try to convert to HTML and thence to PDF ...

enter image description here

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • Thanks a lot. This is very encouraging what you have just showed. I have however converted from rmd to md and just then to pdf (I have tried both ways, from html and from md as well). I'm accepting your answer since you showed that it is possible. I will just figure out what's wrong on my side. I will post my results and findings. Thanks. – Maximilian Aug 22 '13 at 17:17
1

So this is just a follow up on Ben answer:

All is needed basically is to save the R markdown editor with encoding. By changing the default saving from ISO-8859-1 to UTF-8.

The rest is as Ben described, so from rmd > md > pdf.

Maximilian
  • 4,177
  • 7
  • 46
  • 85
0

Markdown is the simplest of the input languages for knitr and while it is great for basic things it quickly falls short when you want to go beyond the basics. It is probably better to use a template based on LaTeX if you want to use the diacritics or other more advanced features.

Greg Snow
  • 48,497
  • 6
  • 83
  • 110