# Detect space before a footnote

I'm in the middle of proofreading TeX source for a book, and have found a couple of places where a stray space has slipped through before a footnote mark. Is there any automated way of scanning TeX source to detect this?

-
I'd like to add a 'proofreading' tag here, if no one objected. I think there is a class of otherwise disparate activities which naturally fall under that tag. –  Mohan Dec 15 '12 at 12:54

If you're running linux or OSX or cygwin under Windows, you can use

grep -n '$$[[:space:]]\|^$$\\footnote' file.tex


in a terminal. This command outputs each line of file file.tex (prefixed with line number) that contains \footnote preceded by a space (any type of space) or at the beginning of a line.

-

The answer depends whether you are proofreading the PDF or the *.tex source. While there may be a possibility to search via »regular expressions« through a PDF looking for footnote numbers, I have no idea how to do that.

But for the *.tex source in the editor there should be a very easy solution: All editors I know provide a funcitionality called »search and replace«. You just have to search for _\footnote{ and replace that by \footnote{ .

Edit: As serveral comments demand to be as precise as possible, I admit that this would be usefull. So I correct: "_" meant a whitespace and certainly it would be a good idea to search and replace two leading whitespaces before a footnote, as well.

-
Does '_' match against whitespace in standard r.e.s? –  Mohan Dec 16 '12 at 11:05
Nitpick: that would not work for this \footnote{\dots} that is preceded by two spaces. Tab characters also pose a problem, as do footnote commands at the beginning of a line. –  Christian Lindig Dec 16 '12 at 11:20