use*_*823 7 pdf yaml r pandoc r-markdown
这是一个最小的工作示例。
---
date : 2018-May-26
output:
pdf_document
title: "Testing Rmarkdown"
---
```{r,comment = NA}
Gender <- gl(2,1000,labels = c("Men","Women"))
SmokerM <- sample(c("Y","N"),1000,replace = T , prob = c(.3,.7))
SmokerW <- sample(c("Y","N"),1000,replace = T , prob = c(.5,.5))
Smoker <- c(SmokerM,SmokerW)
mydata <- data.frame(Gender,Smoker)
table(mydata$Gender,mydata$Smoker)
```
This is a text in the body of the document.What font is this ? What is
font for the output of table ? How can we change these 2 fonts ? What
other categories of items are there in an Rmarkdown which have different
fonts ?
Run Code Online (Sandbox Code Playgroud)
我的查询如下: Rmarkdown 文档的默认字体是什么以及如何更改它们?
在研究这个时,我遇到了这个页面:
[Pandoc 变量][1] http://pandoc.org/MANUAL.html#variables-for-latex
是否有 4 种字体(mainfont/sansfont/monofont/mathfont)用于描述 Rmarkdown 中的 4 类输出?它们的默认值是什么,我该如何更改它们?
创建 PDF 文件时使用 LaTeX。LaTeX 中使用的默认字体是 Computer Modern。有多种方法可以更改 LaTeX 中使用的字体,但如果不了解 LaTeX,所需的名称通常不直观。一个更简单的解决方案是将mainfontetc. 与引擎一起使用xelatex或lualatex作为引擎使用。您可以yml使用平台的标准字体名称在标题的顶层定义这些选项。这里使用 Liberation Serif 作为主要字体的示例文档:
---
date : 2018-May-26
output:
pdf_document:
latex_engine: xelatex
mainfont: LiberationSerif
sansfont: LiberationSans
monofont: LiberationMono
title: "Testing Rmarkdown"
---
```{r,comment = NA}
Gender <- gl(2,1000,labels = c("Men","Women"))
SmokerM <- sample(c("Y","N"),1000,replace = T , prob = c(.3,.7))
SmokerW <- sample(c("Y","N"),1000,replace = T , prob = c(.5,.5))
Smoker <- c(SmokerM,SmokerW)
mydata <- data.frame(Gender,Smoker)
table(mydata$Gender,mydata$Smoker)
knitr::kable(table(mydata$Gender,mydata$Smoker))
```
This is a text in the body of the document.What font is this ? What is
font for the output of table ? How can we change these 2 fonts ? What
other categories of items are there in an Rmarkdown which have different
fonts ?
Run Code Online (Sandbox Code Playgroud)
第一个表使用mono字体,即Liberation Mono,因为它是正常的R输出。第二个表再次使用主字体。有关更多详细信息,请参阅文档。
| 归档时间: |
|
| 查看次数: |
8349 次 |
| 最近记录: |