我试图让一些R代码适合我的beamer幻灯片。 似乎不可能通过代码块的size
参数来更改字体大小,就像你可能为其他knitr类型文档所做的那样。唯一的方法似乎是在每个代码块之前使用\footnotesize
。这很令人沮丧,因为我有很多代码块,在许多情况下,我还必须在LaTeX项目符号后使用\normalsize
。
---
title: "Untitled"
output:
beamer_presentation:
includes:
in_header: header.txt
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, size = "footnotesize")
```
## R Markdown
```{r}
summary(cars)
```
\footnotesize
```{r}
summary(cars)
```
在我的header.txt
文件中(如下所示),我尝试使用了http://yihui.name/knitr/demo/beamer/上的一些代码,但都没有成功。
\ifdefined\knitrout
\renewenvironment{knitrout}{\begin{footnotesize}}{\end{footnotesize}}
\else
\fi
\makeatletter
\let\oldalltt\alltt
\def\alltt{\@ifnextchar[\alltt@i \alltt@ii}
\def\alltt@i[#1]{\oldalltt[#1]\footnotesize}
\def\alltt@ii{\oldalltt\footnotesize}
\makeatother
... 但实际上我在\def
方面很不熟练。
knitr::opts_chunk$set(collapse = TRUE)
,那么我就不需要担心你的verbatim
修复(在幻灯片中其他地方使用时有连锁反应),因为 R 输出也在阴影区域中。 - guyabelLaTeX Error: Environment Shaded undefined.
有什么想法吗? - Philip Leifeld