Question

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.

Basic example showing partial .tex output from knitr compile:

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}

enter image description here

Was it helpful?

Solution

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

\renewenvironment{knitrout}{\vspace{1em}}{}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top