Maximilian
Maximilian

Reputation: 4229

Knitr and R markdown doc with diacritics

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.

Upvotes: 2

Views: 1776

Answers (3)

Maximilian
Maximilian

Reputation: 4229

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.

Upvotes: 1

Ben Bolker
Ben Bolker

Reputation: 226087

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

Upvotes: 2

Greg Snow
Greg Snow

Reputation: 49640

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.

Upvotes: 0

Related Questions