r - Knitr - 更改图表中段落之间的空格失败
问题描述
我想减少我的 Rnw 文件(LateX+R+Knitr)中块之间的空间。我遇到了以下适用于文本输出的 Rnw 文件:https ://gist.github.com/yihui/2760395#file-knitrout-parskip-rnw 。如果您有图表,则没有 - 图表向上移动太远,代码和图表重叠。是否有可能重新定义 knitrout 以影响输出文本而不是图表?我不知道如何附加 pdf 输出,但下面是代码。
\documentclass{article}
% change the space between paragraphs in chunks
\ifdefined\knitrout
\renewenvironment{knitrout}{
\setlength{\parskip}{-1in}
}{
\setlength{\parskip}{0in}
}
\else
\fi
\begin{document}
The quick brown fox jumps over the lazy dog the quick brown fox jumps over the
lazy dog the quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog the quick brown fox jumps over the
lazy dog the quick brown fox jumps over the lazy dog.
<<test>>=
set.seed(77)
1+1
(x <- rnorm(30))
@
The quick brown fox jumps over the lazy dog the quick brown fox jumps over the
lazy dog the quick brown fox jumps over the lazy dog.
<<fig.height=3>>=
plot(x)
@
The quick brown fox jumps over the lazy dog the quick brown fox jumps over the
lazy dog the quick brown fox jumps over the lazy dog.
\end{document}
解决方案
最后我在这里找到了解决方案。
\usepackage{etoolbox}
\makeatletter
\preto{\@verbatim}{\topsep=-1em \partopsep=-1em }
\makeatother
推荐阅读
- opencv - 检测反射物体的边缘
- sql - posgresql - in 子句到布尔值
- java - 初学者Java项目:如何从数组中删除一个元素,当它是参数之一?
- reactjs - 在 React 中上传时无法预览图像
- excel - 根据行数和循环突出显示行
- javascript - 以 HTML 表格形式检索数据(但 HTML 代码与从中加载数据的表格相同)
- sql - Teradata SQL:计算错误代码连续出现的次数(并在不发生时重置)
- reactjs - 在路由更改时保持 redux 状态
- javascript - 用于多个括号打开和关闭的正则表达式
- outlook - 不在 Outlook Web 中时如何使用 officejs 保存文件?