我想在 rmarkdown 文档中设置基本图的默认字体,但我意识到它不起作用。 有谁知道如何在 rmarkdown (html) 中为基本图形设置默认字体
---
title: "Setting font in par"
output: html_document
---
The way of setting default font for base graphics is to use par
```{r}
par(family = "monospace")
```
Setting the default does NOT work in Rmd while executing directly in terminal does
```{r}
plot(1:10, main = "title") # output of rmarkdown::render does not use the right font
# but execution in a terminal does
```
Specifying it explicitely does work
```{r}
plot(1:10, main = "title", family = "monospace")
```
每个代码块都在单独的图形设备内进行评估,这意味着前一个块中的
par()
之类的设置不会传递到下一个块。如果你想让这些设置持久化,你需要设置选项:
knitr::opts_knit$set(global.device = TRUE)