How to perform advanced spell checking of latex documents?
You can use the detex tool to strip LaTeX commands. If you do detex file.tex
, it will output to stdout. Then, you can use the diction tool to analyse your text, and suggest improvements. Putting it all together:
detex file.tex | diction -bs
This will strip the LaTeX, and pipe it into diction with suggestions and "beginner mistakes" enabled.
For Debian/Ubuntu:
sudo apt-get install diction texlive-extra-utils
This will install detex and diction, as well as several other useful tools.
Since you mentioned that you're using Emacs, there is also diction.el which provides diction integration with Emacs. You can do M-x diction-buffer
, and it will take care of detexing/dehtmling and show the diction results in a separate buffer. You can even hit enter on the individual results to be taken to approximately where the phrase is.
(If you do use diction.el, my version of detex didn't have the -C flag. I'm not sure of what it was meant to do, but if you search for 'detex -C' in the file, you can add other command line options if you want. Also, I recommend replacing 'diction -L' with 'diction -bsL')
(This is a repeat of my post on a different thread.)
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:
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.)
aspell -t -c <filename>
where < filename > is the name of the tex file you would like to spell check will also do the job if aspell (http://aspell.net/) is installed on your system. Here -t filters the tex keywords and the symbols and -c asks aspell to spellcheck.