【问题标题】:How to change font size and type in the middle of a R markdown document?如何在 R Markdown 文档中间更改字体大小和类型?
【发布时间】:2019-09-24 01:59:43
【问题描述】:

例子:

---
output: pdf_document
mainfont: Times New Roman
fontsize: 12pt
spacing: 1.1
geometry: "left=1in,right=1in,top=0.5in,bottom=1in"
vspace: 4pt
---

This line is normal text.

This line uses Garamond font and font size 14.

This line uses arial font and font size 16.

This line is normal text.

我尝试了几个选项,但都没有奏效。如果有办法,请告诉我。

【问题讨论】:

  • 这确实是一个 LaTeX 问题,不幸的是,不是 R 或 Rmd 问题。搜索tex.stackexchange.com,您可能会找到几个选项。

标签: r latex r-markdown


【解决方案1】:

我们可能会在您的 rmarkdown 脚本中使用 LaTeX 代码。用\fontfamily{}设置字体类型,部分字体代码可以在here找到。 (请注意,我在这里使用的是 Palatino,因为我的系统上可能没有安装 Garamond。)字体大小可以使用 \fontsize{}{} 设置,其中第一个 {} 代表大小,第二个代表间距。为了使这只是暂时的,我建议将其嵌入\begingroup\endgroup。保持 YAML 标头不变。

This line is normal text.

\begingroup
\fontfamily{ppl}\fontsize{14}{16}\selectfont
This line uses Garamond font and font size 14.
\endgroup

\begingroup
\fontfamily{phv}\fontsize{16}{18}\selectfont
This line uses arial font and font size 16.
\endgroup

This line is normal text.

结果

【讨论】:

    猜你喜欢
    • 2015-05-30
    • 2021-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-23
    • 2013-08-20
    • 2017-08-13
    相关资源
    最近更新 更多