[Tex/LaTex] Why does chktex lint “command terminated with space”

chktexmacros

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.

Best Answer

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.

Related Question