How to write special characters in latex documents RMarkdown?

I am trying to write an article in RMarkdown pdf. But I don’t know how to use special characters like "İ, ı,", ü, ö. These characters are in Turkish. I can easily use them in latex, for example, \ u {g} - ğ, \ c {c} - ç, \ "{u} - ü, {\ i} - ı, etc.

Could you tell me how I can do the same in RMarkdown?

And where can I find some Rmarkdown documents or book templates?

+4
source share
4 answers

HTML codes for Turkish characters will work (example from wikipedia ):

--- title: "My doc" output: pdf_document --- HTML char detail anglicized ------- -- ------------------------------ --- Ğ Ğ Uppercase "G" with breve accent gh1 İ İ Uppercase dotted "I"² i (as in "tree") Ş Ş Uppercase "S" with cedilla sh ğ ğ Lowercase "g" with breve accent gh1 ı ı Lowercase dotless "i"³ ou (as in "in") ş ş Lowercase "s" with cedilla sh ------- -- ------------------------------- -- 

What makes PDF this way:

enter image description here

For article templates see rticles or make your own

For book templates, check out pandoc ebook , gitbook, and bookdown


This xelatex option, which I originally proposed, will not work for Turkish characters:

xelatex engine is recommended for this kind of thing. Then you can access your system fonts using the mainfont argument :

 --- title: "My doc" output: pdf_document: latex_engine: xelatex mainfont: "name of your system font that has all those characters" --- PDF output will be in the font you specify. Just type as normal with no special codes. 
+6
source

rmarkdown uses LaTeX to create a PDF file, so you should just use LaTeX markup. As an example:

 --- title: "Test" output: pdf_document --- This is a special character: \u{g}. 

In addition, depending on the specific characters, you can simply enter them in as-is (see, for example, here ).

+2
source

I think this question is out of date by itself. At the moment ( rmarkdown V1.4 / knitr V1.15.1), knitr automatically follows the advice of this issue and automatically includes

 \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} 

in the preamble to LaTeX (caution: this means that your document editor will have to use UTF-8, but, for example, RStudio does this by default).

Then it works as expected:

 --- title: "Test" output: pdf_document --- Here are some special characters: İ ı Ş Ğ ş ğ ö ü 

This is not a panacea, as many scenarios still require more skill (I tried Korean, Chinese and Japanese). See here to start reinforcing the preamble if you need more varied fonts.

+1
source

If you need special characters for other languages ​​in addition to Turkish, it looks like you can enter the code shown on this web page:

http://www.starr.net/is/type/htmlcodes.html

Be sure to turn it on ;

0
source

All Articles