13

I need a "\smartmedskip" feature/macro in plain TeX which is in usual identical to \medskip, however, if we are right after display math mode, then it should be just "disabled", i.e. it should then behave as \par (or \vskip0pt).

(I want to use this in a macro that inserts exercises to my exercise list. Now if the last line of an exercise is a math formula, then in sum I get too much space between this and the next exercise.)

Thanks in advance.

1

1 Answer 1

14

You probably want that it does nothing whenever it follows another vertical skip:

\def\smartmedskip{\par
  \ifdim\lastskip>0pt \else \medskip\fi
}

This will be followed by a {\tt\string\medskip}.

\smartmedskip

This has a displayed formula
$$
a+b+c+d+e+f+g+h+i+j+k+l+m+n
$$
\smartmedskip
but the {\tt\string\smartmedskip} does nothing.

This has a displayed formula
$$
a+b+c+d+e+f+g+h+i+j+k+l+m+n
$$
\medskip
and we check the difference.

\bye

enter image description here

1
  • Wow, thanks for the quick reply. This solution does what I want. (In fact, I knew about \lastskip, but I did not know that it indicates \belowdisplayskip, too.) Feb 24, 2014 at 17:59

You must log in to answer this question.

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