在已编译的pdf中的文档文本和knitr代码块之间添加空间 [英] add space between document text and knitr code chunk in compiled pdf

查看:155
本文介绍了在已编译的pdf中的文档文本和knitr代码块之间添加空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用RStudio(0.98.501)将带有R代码块的.Rnw编译为pdf.在生成的PDF中,文档文本和R代码块之间没有空格.我没有遇到任何允许我指定文本块和代码块之间的垂直空间的knitr块或包选项.我想在文本和代码块之间再添加一行.我正在寻找全球解决方案;在每个代码块无法复制之前,手动添加垂直空间.

I am using RStudio (0.98.501) to compile a .Rnw with R code chunks into a pdf. In the resulting PDF, there is no space between document text and R code chunks. I have not come across any knitr chunk or package options that let me specify vertical space between text and code chunks. I'd like to add one more line in between the text and the code chunk. I'm looking for a global solution; manually adding vertical space before each code chunk would not be reproducible.

基本示例显示了knitr编译的部分.tex输出:

Basic example showing partial .tex output from knitr compile:

VCCT测试日期的直方图:

Histogram of VCCT test dates:

\begin{knitrout}
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
\begin{alltt}
\hlcom{# sort}
  \hlstd{vcct.base} \hlkwb{<-} \hlstd{vcct.base[}\hlkwd{do.call}\hlstd{(order, vcct.base[}\hlkwd{c}\hlstd{(}\hlstr{"date.test.vcct"}\hlstd{)]), ]}
...
\end{alltt}
...
\end{knitrout}

推荐答案

必须有几种方法可以做到这一点.例如,您可以定义knitrout环境:

There must be several ways to do this. For example, you can define the knitrout environment:

\renewenvironment{knitrout}{\vspace{1em}}{}

这篇关于在已编译的pdf中的文档文本和knitr代码块之间添加空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆