Rmarkdown中一组特定行的Calibri字体

问题描述

这是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字体,而不是认字体。

解决方法

如果可以将乳胶引擎设置为xelatex,则可以使用\fontspec{Calibri}将字体设置为Calibri,然后使用\normalfont返回默认字体。

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

knitted pdf