0

What is the proper way of preventing my new command from eating following space? I define it as follows:

\newcommand\ISPPA{I\textsubscript{SPPA}}

To use it in text as such:

the \ISPPA{} for bla bla

Is there a way without requiring the braces? And either way is my new command alright or am I missing some best practice and might mess up spacing etc?

Anna
  • 811
  • 3
    Yes. Macros without an argument generally "eat" space that follows them. The standard ways to avoid that are by supplying empty curly braces the \ISPPA{} for or using a control space the \ISSPA\ for. There are other methods, but those either lead to a non-standard syntax or make your macro inconsistent with other LaTeX-defined macros and their space-eating behaviour. See also https://tex.stackexchange.com/q/31091/35864. – moewe May 27 '22 at 13:07
  • 2
    To summarize that link: it's not hard to have the newcommand create the space that you want, but then \ISPPA, becomes "ISPPA ,". You can counter that with the xspace package, but then you still need to look through your document to make sure it's doing things correctly. And if you need to look through your document, you might as well leave out xspace and do things by hand anyway. – Teepeemm May 27 '22 at 13:30
  • Thank you both! – Anna May 27 '22 at 13:32
  • \ISPPA gets tokenized as a control word token by TeX's reading apparatus. After tokenizing a control word token the reading apparatus switches to state S (skipping blanks). This is hardwired in TeX. You can have \ISPPA surrounded by non-control-word-tokens that trigger state M(middle of line). E.g., \newcommand\foo[1]{#1}...the \foo{\ISPPA} for bla bla. Instead of a control-word-token you can define a control-symbol-token (control sequence token whose name is a single non-letter) or an active character token. TeX's reading apparatus switches to state M after tokenizing such tokens. – Ulrich Diez May 27 '22 at 14:55
  • \uppercase and \lowercase don't "look" at the expansion of macros, thus you could do the \lowercase{\ISPPA} for bla bla... or the \uppercase{\ISPPA} for bla bla... ;-) – Ulrich Diez May 27 '22 at 15:04

0 Answers0