Rmarkdown 中一组特定行的 Calibri 字体

Calibri font for a particular set of line in Rmarkdown

这是一个可重现的 PDF Rmarkdown 示例:

---
title: "Untitled"
output: pdf_document
---

```{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>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r cars}
summary(cars)
```

我需要 “这是一个 R Markdown 文档。Markdown 是一种用于创作 HTML、PDF 和 MS Word 文档的简单格式语法。有关更多详细信息使用 R Markdown 参见 http://rmarkdown.rstudio.com."

使用 Calibri 字体而不是默认字体。

如果您可以将 Latex 引擎设置为 xelatex,您可以使用 \fontspec{Calibri} 将字体设置为 Calibri,然后 \normalfont 至 return 为默认字体。

---
title: "Untitled"
output: 
  pdf_document: 
    latex_engine: xelatex
---

## R Markdown

\fontspec{Calibri} 

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>.

\normalfont

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this: