\addvspace can be used to create commands which can be stacked together without creating unnecessary padding. This is useful for creating commands which start and end with \addvspace so that they can be placed adjacent to each other without using up twice as much padding space as they need. Does anyone know of a similar command for horizontal space? I have a number of commands of the form


that I would like to string together, but I only want them separated from each other by 1ex each. (And I want to use commands in the interim that don't have \hspace in them, so just cutting the space down to 0.5ex is not a solution.) Any thoughts?


I don't know about an \addvspace version for horizontal spacing but in your case you could add an \unskip at the begin of the macro to remove any prior \hspace or other skips caused by normal spaces:






Text \oldfooAnd\oldfooAnd\oldfooAnd text

Text \fooAnd\fooAnd\fooAnd text


Compare the results:



This is an adaptation of \addvspace:


        \hskip \@tempskipb
    \ifdim \lastskip =\z@
      \hskip #1\relax
    \errmessage{\noexpand\addhspace not in horizontal mode}%


\addhspace{2cm} % this issues an error message!


  • Unfortunately this doesn't work any more with TL 2020: \addhspace ...d \addhspace not in horizontal mode} \fi l.33 \addhspace{2cm} – Florian Nov 2 '20 at 10:20
  • 1
    @Florian The first \addhspace{2cm} is supposed to produce the error message! I added a comment to clarify. – egreg Nov 2 '20 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy