[Tex/LaTex] Reduce space before and after an environment

environmentsspacing

A simple(?) question, how do I reduce the space before and after a environment?

I suppose I'm after a redefine environment command that I can put at the top of my document.

Example

I'm using Sweave and the R highlight environment. Basically, R code gets transformed into latex code. The end latex result looks like this:

\begin{Hchunk}
  \begin{Hinput}
     \ttfamily\noindent
     \hlprompt{\usebox{\hlnormalsizeboxgreaterthan}{\ }}<snip>
     \normalfont
   \end{Hinput}

   \begin{Houtput}
     \ttfamily\noindent
      NC-17{\ }{\ }{\ }{\ }PG{\ }PG-13{\ }{\ }{\ }{\ }{\ }<snip>
   \end{Houtput}

 %A few more Hinput and Houtput environments.
\end{Hchunk}

I would like to reduce the space after \end{Houtput} For example \end{Houtput}\vspace{-0.2em}

Best Answer

The highlight package seems to define

\newenvironment{Hinput}{}{}
\newenvironment{Houtput{}{}
\newenvironment{Hchunk}{%
\vspace{0.5em}\noindent\begin{lrbox}{\highlightbox}%
\begin{minipage}[b]{.9\textwidth}%
}{%
\end{minipage}\end{lrbox}%
\fcolorbox{highlightBorder}{highlightBg}{\usebox{\highlightbox}}%
\vspace{0.5em}
}

You can change those to be more suitable to what you want. In particular, you can remove the \vspace. Just use \renewenvironment.