Grammar-checking tool for use with LaTeX?

(It's not too polite to answer your-own questions, but this is what I ended up with.)

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 :)


I wrote a grammar checker for checking TeX documents called LyX-GC. It can also be used online as a web app.

It can use LanguageTool as a back-end. The main advantages over just using LanguageTool directly are that (1) it filters the TeX to avoid false positives from LanguageTool trying to interpret TeX commands as English and (2) it has hundreds of is own rules, including TeX-specific rules. For example, it knows that "See \ref{lem:foo}" should really be "See Lemma \ref{lem:foo}". (Also, if you use LyX, LyX-GC obviously has the advantage of being able to integrate with LyX.)

LyX-GC only really supports English (though there is experimental French support in the git repository).


I've just finished writing a new tool for checking spelling and grammar directly on LaTeX files, called TeXtidote:

https://sylvainhalle.github.io/textidote

The program can remove markup from the file and send it to the Language Tool library, which performs a verification of both spelling and grammar in a dozen languages. What is unique to TeXtidote is that it keeps track of the relative position of words between the original and the "clean" text. This means that it can translate the messages from Language Tool back to their proper location directly in your source file. By default, TeXtidote produces an HTML report that shows your original sources, with the errors found by Language Tool highlighted at the correct location:

Screenshot

The tool is free and easy to install (OS-independent, requires Java). I encourage you to give it a try and tell me what you think! (More information about download/install/use can be found on the Readme page of the GitHub repository; click on the "Download" button on the web site to get there.)