[Tex/LaTex] Controlling space between lines of knitr output

knitrline-spacing

I have prepared a Rtex document for processing by knitr. Is it possible to have the LaTeX output from knitr single spaced while the remainder of the LaTeX document is double spaced? If so, what are the chunk options in knitr?

Best Answer

I figured out a solution by recognizing that knitr creates a new LaTeX environment, knitrout. Therefore, you can specify single spacing within that environment by placing the following statements in the preamble of the Rtex file:

\usepackage{etoolbox}

\AtBeginEnvironment{knitrout}{\singlespacing}