[Tex/LaTex] Grammar-checking tool for use with LaTeX

grammarlinuxproofreadingspelling

I am looking for a grammar-checking tool, i.e., something that checks for mistakes such as "two dog" or "a books". It has to work on Linux (Ubuntu). Also, since I use macros to generate some of the prose, it has to somehow work with LaTeX. I don't think that such checkers are LaTeX-aware, so it has to work with some compilation product of LaTeX: DVI or PDF.

If you suggest a grammar checker that checks plain text, please explain how to you extract the text. catdvi does a nice job, but it leaves some garbage like page numbers.

Best Answer

LanguageTool is a very nice standalone, Java-based grammar checker. However, it works on plain text. Therefore, I needed to convert my LaTeX document to as plain as possible text document - Not a simple task. I managed to do it using the following trick:

  1. I arranged for all floats to hold their positions using the floats package and the H option. This is required so that captions won't break the paragraphs when transforming to plain text.
  2. I removed line numbers using the nopageno package.
  3. I used a sed script to do some more fine-tuning, like adding periods to section names and description labels. I don't publish the script here, since that it is really specific to my-own style and conventions.
  4. After this preprocessing, I compiled to DVI and ran catdvi -s.
  5. I used another simple sed script to get rid of empty lines and page breaks. The final result is a reasonable textual conversion of the LaTeX document, which LanguageTool can work on.

There are still some leftover annoyances, like inlined program listings, which the grammar checker can't understand, but all together I got a decent automated proof-checking from it :)