有没有简单的解决方案,以获得rmarkdown PDF表无衬线字体?在普通文本,代码和公式的字体应保持不变。我要求很高的xtables
。
例:
---
title: ''
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo=TRUE)
```
```{r ranking tradeoff, results='asis', message=FALSE, echo=FALSE}
library(xtable)
print(xtable(mtcars[1:2, ])
, include.rownames=TRUE
, comment=FALSE
)
```
在表中的文本应该出现在无衬线字体。
我试图this解决方案,但它并没有为我工作。该字体不发现,尽管该powershell font check会变得不一样。然而,字体例如命名“解放三世”,而不是“LiberationSans”。因此,我试图指定sansfont: "Liberation Sans"
没有成功。也有出现使用时asmath
是一个包冲突mathtools
VS xelatex
。
你可以定义字体的一个新的环境,并与latex.environments
的print.xtable
选择使用。
\newenvironment{myfont}{\sffamily}{}
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo=TRUE)
```
```{r ranking tradeoff, results='asis', message=FALSE, echo=FALSE}
library(xtable)
print(xtable(mtcars[1:2, ])
, include.rownames=TRUE
, comment=FALSE
, latex.environments = "myfont"
)
```