【问题标题】:R markdown - how to switch font to Times New Roman?R markdown - 如何将字体切换为 Times New Roman?
【发布时间】:2016-08-25 22:17:48
【问题描述】:

我放弃了。我在我的 R Markdown 文档中找不到任何可行的解决方案来更改字体类型。我尝试了很多东西,例如:

---
output: word_document    
sansfont: Calibri Light
---

但是 RStudio 只是忽略了它。你能帮助我吗?我的 pdf/word 文档中需要 Times New Roman 字体。

问候

【问题讨论】:

  • 请注意“文档字体(仅适用于 xelatex 和 lualatex,请参阅 latex_engine 选项)”。所以我怀疑你可以为单词输出做到这一点。如果您想要 pdf,请使用 xelatex 或 lulatex。如果 pdf 适合您,那么这可能是 stackoverflow.com/questions/24421235/… 的副本
  • 所以我的word输出中没有更改字体的选项?
  • 是的,可以更改。这可能会有所帮助:rmarkdown.rstudio.com/articles_docx.html

标签: fonts markdown


【解决方案1】:

这对我有用。尝试使用mainfont 而不是sansfont, 并将latex_engine 设置为xelatexlualatex

---
output: 
  pdf_document:
    latex_engine: xelatex
mainfont: Times New Roman
---

【讨论】:

    【解决方案2】:

    另一种选择:对于 pdf 文档,我使用了:

    output: pdf_document
    fontfamily: arev
    

    在我的 YAML 标头中。

    【讨论】:

    • 嗨,我有一个疑问。在我的 YAML 中设置字体和在 YAML 之外设置字体有什么区别?
    • 嗨 Laura,有时您可以在 YAML 之外设置具有级联样式表 (css) 的字体。
    • 只是要注意,当上面的答案不适用时,这适用于 pdflatext
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-24
    • 1970-01-01
    • 1970-01-01
    • 2011-05-27
    • 2018-10-24
    相关资源
    最近更新 更多