4

Is there a way to swallow one space (or more spaces) before a command? E.g.:

xxx \mycommand{}yyy

which results in

xxxyyy
NVaughan
  • 8,175

1 Answers1

5

I think you're looking for \unskip.

LaTeX version:

\documentclass{article}
\begin{document}    
xxx \unskip{}yyy
\end{document}

Plain-TeX version:

xxx \unskip{}yyy
\bye

The output of both documents is "xxxyyy".

Mico
  • 506,678
  • 1
    Thanks Mico! Is there an equivalent to removing the vertical spaced introduced by environments? – NVaughan Jul 30 '20 at 20:48
  • @NVaughan - Addressing your follow-up question is quite tricky, actually, as you don't specify the types of vertical space or the types of environments that introduce vertical spacing at their end. In principle, \unskip works on "glue" in both "horizontal mode" and "vertical mode". However, \unskip does not work on items (including vertical-mode glue) once they're added to the "main vertical list" on a page. (Warning: Some serious TeX jargon is being thrown about right now!) See this answer for more information. – Mico Jul 31 '20 at 15:03
  • Thanks. I'll give it a look. – NVaughan Jul 31 '20 at 22:18