简体   繁体   English

在 R Markdown PDF 文档中的单个块中更改 output 的字体大小

[英]Change font size for output in a single chunk in R Markdown PDF document

I have an R Markdown with bookdown document that has several chunks of R code.我有一个 R Markdown 和 bookdown 文档,其中有几块 R 代码。 After each chunk I output the resulting tibble table is output. I have one tibble output that has several columns that move out of the margin and am trying to figure out how to reduce the font size of this one particular chunk (leaving all out chunks output unchanged).在每个块 I output 之后,生成的 tibble 表是 output。我有一个 tibble output,它有几列移出边距,我试图弄清楚如何减小这个特定块的字体大小(留下所有块 output不变)。 I want to leave the "echoed" code font size unchanged.我想保持“回显”代码字体大小不变。

Is this possible?这可能吗? I've read a few of the other posts here but all seem to address global font size changes, rather than one for a particular chunk.我在这里阅读了一些其他帖子,但似乎都解决了全局字体大小的变化,而不是针对特定块的。

Thanks in advance for any help.在此先感谢您的帮助。

Here is my YAML header too:这也是我的 YAML header:

header-includes: |
  \usepackage{amsmath}
  \usepackage{indentfirst}
  \usepackage{hyperref}
  \usepackage[utf8]{inputenc}
  \def\tightlist{}
  \setlength\parindent{24pt}
output: 
  bookdown::pdf_book:
    base_format: rticles::tf_article

You could use htmltools with results='asis' inside chunck, or with r... outside chunck:您可以在htmltools内使用带有results='asis'的 htmltools,或者在 chunck 外使用r...

```{r, results = 'asis',echo = F}
htmltools::h3("Test big font")
htmltools::h4('Test medium font')
htmltools::h5('Test smaller font')
```
`r htmltools::h3("Outside chunck")`

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM