1

I am currently writing a quite large report with many different .tex files. I have found some utilities (aspell, ispell ...) that are able to deal with a single file.

Is there some command that will spellcheck all files in my project?

2

As you mentioned a good starting point is aspell. With that being said, I wrote a one line script that finds all tex files, detex them and pipe them into aspell:

find . -name \*.tex | awk '{print "echo "$0" && detex "$0" | aspell -a list"}' | bash | grep -Ev '(^$|^\*)' > misspelled.log

or in multi-line:

find . -name \*.tex | \
awk '{print "echo "$0" && detex "$0" | aspell -a list"}' | \
bash | \
grep -Ev '(^$|^\*)' > \
misspelled.log

First line finds all the tex files and pipe it to the awk command. What Awk pipes to bash does the following:

  1. print the address of the file (for easier track of misspelled words)
  2. detex the file
  3. pipe detexed file to aspell.

The output of aspell is then sent to grep for filtering empty lines and somehow useless outputs of aspell. If you look at the aspell -a output, there are some empty lines as well as lines that hold only an asterisks. Regular expression (^$|^\*) detect these lines and print those lines that does not contain this pattern.

Know issue:

As you know detex is not perfect and this directly affect the output of this script. You can however, add a white list of words to aspell by passing --personal argument to filter out some of imperfections.

You can also add a second grep filter to remove suggestions from the final output.

Sample output:

./abstract.tex
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.7-20110707)
& gratitudes 2 11: gratitude's, gratitude
& confgiruation 4 4: configuration, configurations, configuration's, reconfiguration
& includegraphics 2 2: include graphics, include-graphics

As you see, the last line is where it has failed! Also, if you want to have line number added to your output file, you should modify the script slightly (follow this stackoverflow question).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.