2

I have a new environment that is defined with addvspace at the beginning and end. This works fine if it is surrounded by text. Now, I want this space to be smaller (smallskipamount) between these environments if they follow one another directly. In other words I want the space to be smaller between the environments than it is between the environments and the text. How can this be achieved?

\documentclass{article}

\usepackage{blindtext}

\newenvironment{env}
    {\addvspace{\bigskipamount}\bfseries}
    {\par\addvspace{\bigskipamount}}

\begin{document}
\blindtext

\begin{env}
Bla bla bla.
\end{env}

\blindtext

\begin{env}
Bla bla bla.
\end{env}

\begin{env}
Bla bla bla.
\end{env}

\blindtext

\end{document}

enter image description here

6
+50

You can store the "message" in the main vertical list about the end of previous environment using very specific value of penalty. And you can read this value at the start of your environment.

\newenvironment{env}
    {\ifnum\lastpenalty=12345 \vskip-\bigskipamount \penalty0 \fi
     \addvspace{\bigskipamount}\bfseries}
    {\par\addvspace{\bigskipamount}\penalty12345 }

The \penalty0 is inserted before \addvspace in order to \addvspace works in the case of vskip correction.

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.