35

Why does chktex lint "command terminated with space"?

Applying {} to the command will disable the lint, but this is tedious to do for all commands.

1 Answer 1

39

When reading the code, TeX gobbles spaces directly following a control word.

Compare

\LaTeX is great.

enter image description here

vs

\LaTeX{} is great.

enter image description here

In this case a warning makes sense.

I am assuming TeX was designed this way because in TeX programming it improves readability if you are able to insert spaces.

Please note that spaces are ignored after control words only, not after control characters or active characters. Consequently ~␣ would insert two spaces and should therefore be avoided.

A control word starts with exactly one character of catcode 0 (usually \) and is followed by an arbitrary number (greater than 0) of characters of catcode 11 (letter). Example: \LaTeX

A control character starts with exactly one character of catcode 0 (usually \) and is followed by exactly one characters which has not catcode 11 (letter). Examples: \␣, \&

An active character is exactly one character of catcode 13. Example: ~

For characters with math code active (for example ') this is irrelevant because spaces are always ignored in math mode, anyway.

2
  • 2
    spaces are often essential after control words because if such a command is followed by another letter it's impossible to know where it ends without the space. and words like \TeX book are meant to not have spaces in them. Commented Sep 19, 2017 at 19:25
  • 3
    But chktex dislike that and want it to be \TeX{}book (or some other acceptable form for it) :s
    – gildux
    Commented Feb 12, 2023 at 19:06

You must log in to answer this question.

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