6

In LaTeX, I would like to define

\newcommand{\ACROeg}{e.\,g.}
This is a sample sentence, \ACROeg it does not make much sense.

but this yields

This is a sample sentence, e.\,g.it does not make much sense.

i.e. the space between \ACROeg and it was gobbled.

I do not want to use \ACROeg{} or \ARCOeg\. Can I define the macro in a way so it does not read into the next token?

arney
  • 2,023
  • 1
    A space after a macro is ignored. The next token after \ACROeg in your example is i, which is not read by the macro. By the way, the definition should be \newcommand{\ACROeg}{e.\,g.\@} so that the period is not considered sentence ending. I'm sure the problem has already appeared on the site. – egreg Oct 15 '14 at 21:03
  • The macro does not read the next token. the space in the source file is never tokenised it is discarded as the terminator of the command name before the definition of the macro is looked up – David Carlisle Oct 15 '14 at 21:04
  • @egreg Thought so, but my search foo was not mighty enough. Thanks for looking up the duplicate. – arney Oct 15 '14 at 21:05
  • @egreg For the sake of completeness: Using xspace.sty, would {e.\,g.\@\xspace} the best choice? And why don't I but \@ after e.? – arney Oct 15 '14 at 21:11
  • 1
    The best choice is to use \ACROeg{}. No \@ is needed after e. because it is not followed by an interword space. – egreg Oct 15 '14 at 21:19
  • 1
    See my new answer to this http://tex.stackexchange.com/questions/31091/space-after-latex-commands/207358#207358 old question. Maybe it is close to your expectations. – Przemysław Scherwentke Oct 15 '14 at 21:36

0 Answers0