在Rmarkdown pdf中更改Kable的字体 [英] Change font of Kable in Rmarkdown pdf
本文介绍了在Rmarkdown pdf中更改Kable的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在编织为pdf时,是否有办法在Rmarkdown中更改电缆的字体?我可以找到很多有关更改大小或加粗等内容的信息,但不能更改实际字体.我只需要没有衬线的东西.
Is there a way to change the font of a kable in Rmarkdown when knitting to pdf? I can find plenty on changing size or bold etc but not on changing the actual font. I would just like something sans serif.
markdown文档示例:
Example markdown doc:
---
title: "R Notebook"
output:
pdf_document: default
---
Change the font in the table below:
```{r message=FALSE, warning=FALSE, echo=FALSE}
library(kableExtra)
mtcars %>% head() %>% kable()
```
推荐答案
You can use the Latex fontspec library, see below. Note that you can see your available fonts and their names in the Fonts page from Settings.
---
title: "R Notebook"
output:
pdf_document:
latex_engine: xelatex
header-includes:
\usepackage{fontspec}
---
Change the font in the table below:
## using the Arial font as an example
\fontspec{Arial}
```{r message=FALSE, warning=FALSE, echo=FALSE}
library(kableExtra)
mtcars %>% head() %>% kable()
这篇关于在Rmarkdown pdf中更改Kable的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文