Reduce space between code chunks and code output in rmarkdown beamer presentation
<p>I'm building a presentation using rmarkdown and LaTeX/Beamer. I would like to reduce the spacing between the displayed R-commands and R-output. I believe this is related to the paragraph spacing options in LaTeX/Beamer.</p>

<p>Is this something I should do in rmarkdown (chunk options, knit_hooks, or something else?), in the pandoc Yaml header (some pandoc option?), or in the LaTeX beamer template file? I feel like it should be in the LaTeX template file. </p>

<p>Below is a working example of a minimal markdown file, and a .tex template file I'm using to control some beamer settings. </p>

<p><strong>example.Rmd</strong></p>

<pre><code>---
title: "Untitled"
author: "Ryan"
date: "March 1, 2016"
output:
  beamer_presentation:
    pandoc_args: '--latex-engine=xelatex'
    includes:
      in_header: latex-topmatter.tex
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Vertical Spacing is too much

Here is a working example.

- some
- bullets

Example code:

```{r, echo = TRUE}
a &lt;- 1
a
a+a
```
</code></pre>

<p><strong>latex-topmatter.tex</strong></p>

<pre><code>% declare overall beamer theme to use as baseline
\usetheme{default}

% make code-output smaller
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{fontsize=\tiny,commandchars=\\\{\}}

% make console-output smaller:
\makeatletter
\def\verbatim{\tiny\@verbatim \frenchspacing\@vobeyspaces \@xverbatim}
\makeatother

% set vertical spacing between paragraphs:
% \parskip{0pt}
% \addtobeamertemplate{blocks}{}{\setlength{\parskip}{0pt}}
% \addtobeamertemplate{block begin}{}{\setlength{\parskip}{0pt}}
% \addtobeamertemplate{block end}{}{\setlength{\parskip}{0pt}}
% % \setlength{\emergencystretch}{0em}
\setlength{\parskip}{0pt}
</code></pre>

<p>I've tried making the font of the R-commands or R-output smaller, which does not seem to affect the paragraph spacing.</p>

<p>I've tried using <code>knit_hooks()</code> as in this example: 
<a href="https://github.com/ramnathv/slidify/issues/189" rel="noreferrer">https://github.com/ramnathv/slidify/issues/189</a>, which mostly works - but then i can't seem to reduce the fontsize of the code and output.</p>

<p>I've also tried using <code>\parskip{0pt}</code>, and several other beamer options or parskip options, which are commented in the above <code>latex-topmatter.tex</code> section. None of them seem to change the spacing between chunks of text, R-code, or R-output. Am I even looking in the right place?</p>

<p><a href="https://i.stack.imgur.com/F5V0D.png" rel="noreferrer"><img src="https://i.stack.imgur.com/F5V0D.png" alt="parskipNotWorking"></a></p>