12

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.

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

  • 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.) – Gábor V. Nagy Feb 24 '14 at 17:59

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.