【问题标题】:Change font of Kable in Rmarkdown pdf在 Rmarkdown pdf 中更改 Kable 的字体
【发布时间】:2019-07-07 06:36:02
【问题描述】:

当编织成 pdf 时,有没有办法在 Rmarkdown 中更改 kable 的字体?我可以在更改大小或粗体等方面找到很多内容,但在更改实际字体方面却找不到。我只是想要一些无衬线字体。

示例降价文档:

---
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()
```

Default table output font

【问题讨论】:

  • 你想改变什么?完全不同的字体系列?只删除衬线?
  • 我在想不同的字体系列。我不知道你可以删除衬线?

标签: fonts r-markdown kable kableextra


【解决方案1】:

您可以使用 Latex fontspec library,见下文。 请注意,您可以在“设置”的“字体”页面中查看可用字体及其名称。

---
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()

【讨论】:

    猜你喜欢
    • 2023-03-02
    • 1970-01-01
    • 2014-08-16
    • 2017-09-13
    • 2017-11-13
    • 2019-10-09
    • 2021-08-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多