3

I have a document that uses multiple custom verbatim environments, created using the fancyvrb package. Spacing around these is controlled by my own code; I have disabled the spacing added by fancyvrb using

\let\FV@ListVSpace\relax

However, when two verbatim environments appear inside an itemize (or other list environment), a vertical space is inserted between them.

\documentclass{article}
\usepackage{fancyvrb}
\DefineVerbatimEnvironment{code}{Verbatim}{}
\DefineVerbatimEnvironment{mapleerror}{Verbatim}{}

\begin{document}
\begin{itemize}
\item 
Implied multiplication is not supported in Maple notation. 
Omitting an asterisk will usually lead to an error message.
\medskip
\makeatletter
\let\FV@ListVSpace\relax
\makeatother
\begin{code}
2 sin( Pi ) ; 
\end{code}
\begin{mapleerror}
Error, missing operator or `;`
\end{mapleerror}
\end{itemize}
\end{document}

spacing

What causes the unwanted space, and how do I get rid of it?

1 Answer 1

4

You have to clear also the internal parameter \@topsepadd; better doing it in a group.

\documentclass{article}
\usepackage{fancyvrb}
\DefineVerbatimEnvironment{code}{Verbatim}{}
\DefineVerbatimEnvironment{mapleerror}{Verbatim}{}

\makeatletter
\newenvironment{tightcodes}
 {\let\FV@ListVSpace\relax\@topsepadd=0pt }
 {}

\begin{document}
\begin{itemize}
\item 
Implied multiplication is not supported in Maple notation. 
Omitting an asterisk will usually lead to an error message.
\medskip
\begin{tightcodes}
\begin{code}
2 sin( Pi ) ; 
\end{code}
\begin{mapleerror}
Error, missing operator or `;`
\end{mapleerror}
\end{tightcodes}

\item Something else
\end{itemize}

\begin{tightcodes}
\begin{code}
2 sin( Pi ) ; 
\end{code}
\begin{mapleerror}
Error, missing operator or `;`
\end{mapleerror}
\end{tightcodes}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .