我正在尝试获取一些 R 代码以适合我的投影仪幻灯片。似乎无法通过更改字体大小size
代码块的参数,就像您对其他knitr类型文档所做的那样。唯一的方法似乎是与\footnotesize
在每个代码块之前。这让人沮丧,因为我有很多代码块,在很多情况下我必须使用\normalsize
之后是我的 LaTeX 要点。
---
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)
```
In my header.txt
(如下)我尝试了一些来自http://yihui.name/knitr/demo/beamer/ 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
.
借鉴这个 tex.SE 答案 https://tex.stackexchange.com/a/2600/56508,我们可以重新定义Shaded
周围的环境R
代码使其脚注大小(以及verbatim
输出环境)。将其添加到您的 header.txt 中:
%% change fontsize of R code
\let\oldShaded\Shaded
\let\endoldShaded\endShaded
\renewenvironment{Shaded}{\footnotesize\oldShaded}{\endoldShaded}
%% change fontsize of output
\let\oldverbatim\verbatim
\let\endoldverbatim\endverbatim
\renewenvironment{verbatim}{\footnotesize\oldverbatim}{\endoldverbatim}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)