Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
525 views
in Technique[技术] by (71.8m points)

r - How can I write special characters in RMarkdown latex documents?

I am trying ot write a paper in RMarkdown pdf. But I dont know how to use special characters like "?, ?, ?, ü, ?". Those characters are present in Turkish. I can easily use them in Latex using e.g. u{g} – ?, c{c} – ?, ”{u} – ü, {i} – ?, etc.

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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"2               i (as in "tree")
Ş     ?     Uppercase "S" with cedilla          sh
ğ     ?     Lowercase "g" with breve accent   gh1
ı     ?     Lowercase dotless "i"3              ou (as in "in")
ş     ?     Lowercase "s" with cedilla          sh
-------   --    -------------------------------   --

Which renders the PDF like this:

enter image description here

For article templates, see the rticles package, or make your own

For book templates, have a look at pandoc ebook, gitbook and bookdown


This xelatex option I initially suggested will not work for Turkish characters:

The xelatex engine is recommended for this kind of thing. Then you can access your system fonts with 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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...