3

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

Eric Green
  • 7,385
  • 11
  • 56
  • 102

1 Answers1

1

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

\renewenvironment{knitrout}{\vspace{1em}}{}
kohske
  • 65,572
  • 8
  • 165
  • 155
  • that's it. thanks, @kohske. i added a space after too. `\renewenvironment{knitrout}{\vspace{1em}}{\vspace{1em}}` – Eric Green Mar 16 '14 at 13:49
  • Thanks @kohske, this looks very promising but does not work yet for me. \renewenvironment{knitrout}{\vspace{1em}}{\vspace{1em}} does not do the trick as is in my preamble.tex file loaded from the yaml header (and working for other latex adds), is this the place and what should I put there? I want to knit directly to PDF in RStudio. Where should I add this code? Thanks in advance – splaisan Mar 18 '20 at 09:56