7

After a \section command, there is the same amount of space regardless of what follows. An itemize environment does not add extra space.

How can I achieve the same behavior after a custom environment?

enter image description here

\documentclass{article}

\newlength{\postinfoskip}
\setlength{\postinfoskip}{2ex}

\newenvironment{info}
  {\itshape}
  {\vspace{\postinfoskip}}

\begin{document}
\section{The spacing after this section \dots}
This is a line of text that begins with a normal amount of space after the section heading.

\section{\dots{} is the same as the spacing after this one}
\begin{itemize}
\item First line of text
\item Second line of text
\end{itemize}

\section{But when I use a custom environment \dots}
\begin{info}
See how much space there is after this environment before normal text.
\end{info}

This is a line of text that begins with a normal amount of space after the environment.

\section{\dots{} I can't get consistent spacing after}
\begin{info}
Compare to the amount of space before itemize.
\end{info}

\begin{itemize}
\item First line of text starts after a gap
\item Second line of text
\end{itemize}
\end{document}
6

In this case I'd suggest using \addvspace rather than \vspace:

\newlength{\postinfoskip}
\setlength{\postinfoskip}{2ex}
\newenvironment{info}
  {\itshape}
  {\par\addvspace{\postinfoskip}}

enter image description here

  • 1
    Thanks! I was reading the latex.ltx and article.cls source to try to figure out \addvspace but I couldn't see why it behaves this way. Could you explain? – musarithmia Sep 26 '16 at 18:24
  • 1
    @AndrewCashner: It adds up to the amount specified, regardless of where it's placed in vertical mode. – Werner Sep 26 '16 at 18:35

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.