German Umlaut characters in R markdown

How to display non-English characters in R-markdown? In another English document, I would like to make a single 'u' with two dots (umlaut) on top of it. This is the correct spelling for 'u' in the name "Muller".

+8
source share
3 answers

You can use standard HTML code for this . For example, the German letter ä can be displayed by placing the corresponding vowel after the ampersand, then uml; , i.e. ä .

Here is an example .Rmd file:

 --- title: "Umlauts with Rmarkdown" output: html_document --- ## This is a sentence with many umlaut characters: Herr Müller sagt: "Über den Wolken können Sonnenuntergänge besonders schön sein." 

enter image description here

+7
source

We can do this better than @RHertel's answer. While explicitly using HTML markup works, it can limit us to HTML output - which is not cool.

Referring to the RStudio documentation, you see that UTF-8 is already used by default (although I made an additional "File → Save with Encoding", which only showed that it was already in UTF-8). Therefore, it is simply a matter of entering the correct Unicode characters. Below is a small version of the standard file that RStudio creates:

 --- title: "Encoding Demo" author: "Dirk Eddelbüttel" date: "2/27/2016" output: html_document --- ## R Markdown Herr Müller sagt: "Über den Wolken können Sonnenuntergänge besonders schön sein." 

which leads to the following HTML:

enter image description here

+8
source

I have a slightly similar - but different - problem: I want to compile a pdf document in English in Rmarkdown, including a bibliography that contains names with "Umlaut" (for example, Pöge). I took care of "Umlaute" in the text, but as soon as I turn on the bibliography in YAML (bibliography: bibliographie.bib), I get the following error message in the R Markdown console

! Inputenc package error: Unicode character ̈ (U + 308) (inputenc) is not configured for use with LaTeX.

Rmarkdown creates a tex file and includes links ... now with "Umlauten". I can find and replace them manually in the tex file, and then the compilation will be successful, but I would prefer to find a solution in Rmarkdown.

My YAML header:

 output: bookdown::pdf_document2: includes: in_header: header_2.tex bibliography: bibliographie.bib biblio-style: "apalike" 

header_2.tex includes the package \ usepackage [utf8] {inputenc}.

To make sure I tried the same settings, but this time I included the link in YAML and the compilation worked like a miracle:

 output: bookdown::pdf_document2: includes: in_header: header_2.tex references: - id: fenner2012a title: Five-click science author: - family: Fänner given: Martin container-title: Mature Materials volume: 11 URL: 'http://dx.doi.org/10.1038/nmatyyy' DOI: 10.1038/nmat3283 issue: 4 publisher: Mature Publishing Group page: 261-263 type: article-journal issued: year: 2012 month: 3 biblio-style: "apalike" 

Can anyone point me in the right direction?

0
source

All Articles