3

I've just stumbled upon chktex, the LaTeX lint. While using it, I've noticed that it keeps giving warnings about needing to remove spaces at the beginning of lines containing only \footnote{Some footnote text}. Nothing in, e.g., this question on spaces at the beginning of lines suggests that this should be problematic, but is it?

Why does chktex complain about spaces at the beginning of a line containing a footnote?

The most minimal of MWEs:

\documentclass{article}

\begin{document}
    \footnote{Some footnote text.}
\end{document}

The chktex warning:

% chktex chktexmwe.tex
ChkTeX v1.7.2 - Copyright 1995-96 Jens T. Berger Thielemann. Compiled with POSIX extended regex support. Warning 42 in chktexmwe.tex line 4: You should remove spaces in front of `\footnote' \footnote{Some footnote text.}
^ chktex: WARNING -- ChkTeX does not handle lines over 1024 bytes correctly. Some errors and line numbers may be wrong in this file. No errors printed; One warning printed; No user suppressed warnings; No line suppressed warnings

5
  • 2
    Can you show a short example where chktex complains about space at the beginning of a line containing only a \footnote? I would be more inclined to complain about a line containing only one footnote than about space preceding it ....
    – moewe
    Aug 26, 2015 at 5:29
  • @moewe Super minimal MWE and text of the warning that chktex generates added to the answer.
    – Dennis
    Aug 26, 2015 at 5:36
  • Er..."question" not "answer".
    – Dennis
    Aug 26, 2015 at 5:46
  • 3
    I think this is because generally spaces before footnotes are not desirable, Lorem \footnote{ipsum} (with a space) gives horrible output. ChkTeX warns you about that, but it does not detect the case at the beginning of a line, where the spaces are ignored. Note though that if you write something like Lorem<linebreak> \footnote{ipsum} you will get a space regardless of the indentation of \footnote{ipsum}, this can only be suppressed with a %, as in Lorem%<linebreak> \footnote{ipsum}. Generally I would advise against \footnote commands at the beginning of lines.
    – moewe
    Aug 26, 2015 at 5:55
  • There are some document styles where footnotes always precede the text they refer to, and so are always preceded by white space. You see that in many English-language bibles, for example. FWIW my personal preference for formatting of the input text for footnotes is Some text\footnote on one line, and {the footnote text} indented (using a tab or spaces) on the following line, or lines. I find this easier to read, especially if there are many footnotes interrupting the "flow" of the main text.
    – alephzero
    Aug 26, 2015 at 12:12

1 Answer 1

6

This is a problem, but only in certain instances. Consider the following minimal example:

enter image description here

\documentclass{article}
\begin{document}
Some text\footnote{abc} with a footnote. \par
Some text \footnote{def} with a footnote. \par
Some text
\footnote{ghi} with a footnote. \par
Some text
  \footnote{jkl} with a footnote.
\end{document}

The \footnote with a preceding space (2, 3 and 4) is obviously incorrect. chktex picks up on this in a very crude or generic way and may miss it on occasion where it should also be avoided (3).

Best would be to use it appropriately the first time around. Strategic placement of % at the end of a line could avoid spacing problem (even though it might still be picked up by chktex). For example,

Some text%
\footnote{ghi} with a footnote. \par
Some text%
  \footnote{jkl} with a footnote.

provides appropriate spacing around the \footnote (for 3 and 4 above), but chktex will still complain about spacing for (4).

2
  • Maybe you could add that if one insists on a line break before a \footnote for some reason, one can salvage the situation by putting a % at the end of the preceding line. In which case 3+% and 4+% do the same and look right again.
    – moewe
    Aug 26, 2015 at 5:59
  • @moewe: Done...
    – Werner
    Aug 26, 2015 at 6:06

You must log in to answer this question.

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