【问题标题】:Changing font in R Markdown to Times New Roman将 R Markdown 中的字体更改为 Times New Roman
【发布时间】:2021-02-22 12:42:33
【问题描述】:

我正在为 uni 写一份报告,并指定我们必须使用 Times New Roman。在我看来,R-Markdown 报告看起来比文字好得多,但我似乎无法更改字体。 这是我文档的顶部:

output: pdf_document
bibliography: miniproject.bib
fontsize: 11pt
mainfont: Times New Roman
geometry: margin=2.5cm

我在编织时没有收到任何错误或未使用的参数警告,但字体似乎没有改变。

谢谢!

【问题讨论】:

  • 欢迎您,@Bex Middleton。尝试将Times New Roman 更改为"Times New Roman"

标签: fonts r-markdown


【解决方案1】:

此代码可能对您有用:

---
title: "Times"
author: "bttomio"
date: "October 18, 2017"
output: 
  pdf_document:
    latex_engine: xelatex
header-includes:
  - \usepackage{fontspec}
  - \setmainfont{Times New Roman}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

另一种选择:

---
title: "Times"
author: "bttomio"
date: "October 18, 2017"
output: 
  pdf_document:
    latex_engine: xelatex
mainfont: "Times New Roman"
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

-输出

【讨论】:

  • 完美,它正在工作!非常感谢!
  • 很高兴听到它对您有所帮助。 @BexMiddleton,可以接受/确认我的回答吗?谢谢!
猜你喜欢
  • 2016-08-25
  • 1970-01-01
  • 1970-01-01
  • 2014-10-28
  • 1970-01-01
  • 2011-05-27
  • 1970-01-01
  • 1970-01-01
  • 2018-10-24
相关资源
最近更新 更多