I hope this is just a matter of taste, but is there any reason not to separate a command from its first parameter with a space? (Or multiple parameters with intervening spaces for that matter.)

\chapter {Introduction}

\setcounter {chapter} {2}

I like the second ones better. This makes prose more readable to me. I was wondering if this can get me into trouble, though.

  • 5
    I don't think there is any difference in the cases that you mentioned. The are potential issues when a trailing parameter is optional (as is the case for the xstring package for example) -- in which case a space preceding the trailing optional parameter will cause the trailing parameter to not be treated as a parameter, but instead will be treated as text following the macro. May 5, 2014 at 2:30
  • 1
    In another context, there might be a LaTeX to Some other language converter, that desperately depends on \command{}, i.e. without spaces between command name and arguments.
    – user31729
    May 5, 2014 at 4:49
  • 2
    From TeX's point of view, there's no difference; spaces after control words are ignored. Also ignored are spaces before arguments (in the normal case of undelimited arguments, the common ones for LaTeX commands).
    – egreg
    May 5, 2014 at 6:54
  • 1
    @PeterGrill The space after \chapter and \setcounter in the question does not exist when TeX has tokenized the input, so it can't be mistaken as an argument.
    – egreg
    May 5, 2014 at 6:56

1 Answer 1


The space after a command name is absorbed while parsing the command name and does not make a token at all. The space between the } { does make a character token, but space tokens are skipped when looking for macro arguments so it is fine to put in the spaces if you wish.

\setcounter {chapter} {2}

Note there is a difference between these spaces; if you go

    \setcounter {chapter} {2}%

In that here, the space after \setcounter really isn't there in the definition of \foo but the space after {chapter} is there, there is a character token so TeX needs to record its value (32) and catcode (10) (although I have a feeling it optimises spaces somewhere, no doubt someone will post the exact line of tex.web) in any case the definition is one or two bytes bigger because of the space. It is unlikely that your documents are big enough that an extra byte will make you run out of memory, but this was a real issue when LaTeX was designed, which is why if you look at the sources of latex and most of the core packages you will see a coding style in which all removable braces and spaces are removed. That doesn't necessarily mean it's a good coding style now:-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .