[texhax] Equivalent of CSS "collapsing margins"?

Edsko de Vries edsko at edsko.net
Thu Oct 25 12:29:22 CEST 2007


Hi,

Is there any way to collapse adjoining \vspace commands? Or better yet,
to define a command, say \vspace*, which behalves like \vspace but
automatically collapse adjoining vertical spaces? For instances,

\vspace*{1em}
\vspace*{2em}

should give a total vspace of 2em. If this is not possible at all,
perhaps a poor-man's version would be a version of vspace where any
subsequent vspace commands are ignored, so that

\vspace*{1em}
\vspace*{2em}

gives a total vspace of 1em. This is not ideal, but better than nothing
:) Of course, when there is any text in between the two calls to
\vspace, the second vspace command should not be ignored. I have
searched for a solution but came up empty. Any hints would be
appreciated!

(This kind of thing is very useful when defining macros for example:
suppose one macro defines a vspace of 2em after the macro expansion, and
another defines a vspace of 1em before the macro expansion; the total
vspace should be 2em, not 3em).

Thanks!

Edsko


More information about the texhax mailing list