5

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}

4
  • 1
    Could you post a small example code showing exactly which space do you want to reduce? Also which environment are you trying to redefine? Sep 9, 2010 at 15:01
  • 1
    The highlight package documentation says that you should just redefine Hinput and Houtput as you desire. Note that using a negative \vspace is almost always the wrong thing to do.
    – TH.
    Sep 9, 2010 at 18:36
  • @TH: If vspace is the wrong thing to do, what's the correct thing to do, i.e. how do you redefine Hinput? Or is this another question? Sep 10, 2010 at 8:17
  • I answered this several days ago. Use \renewenvironment to change the definition of the Hchunk environment.
    – TH.
    Sep 11, 2010 at 22:29

1 Answer 1

3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.