What's the best strategy for spell checking LaTeX documents?
It sort of depends on the system you're working on.
I'm using GNU/Linux and here
aspell does a good job. For instance, to check
test.tex in Danish, I would do like this from the terminal:
aspell -c -t test.tex -d da
aspell to check the file,
-t puts it in TeX mode, and
-d gives the base name of the main dictionary to use.
On Ubuntu/Debian, this can be installed using:
sudo aptitude install aspell
Aspell is also available as a Windows executable. It can but run from the command line or from any good text-editor (i.e. one that supports macros to run external programs).
There's a reasonable on-line spell-checker at Micro Spell.
You might want to have a look at the spelling package. Though not yet matured, it already works reasonably well. The spelling package requires the LuaTeX engine. Main features of the package are:
- Text is extracted during typesetting and written to a file that can be checked by your favourite spell-checker application.
- Spelling errors can be highlighted in PDF output.
(The maintainer of the spelling package.)
Old question but I figured I'd throw in my two cents. An approach that I use, following a careful read-through to make sure that I catch as much as I can, is to first convert the latex document to RTF (using the latex2rtf package), and then open it up in Word. The figures tend to be ignored, however the wording and grammar at least can be handled by Word's excellent spelling and grammar checker.
I use a mac and I have cocoaspell, which works for the whole computer. As I use Aquamacs, I then enable flyspell (spell check on the fly), and it is all done!
It depends not only on the packages suggested but also on the language that you are using and on the front-end you edit your text. If you are a Windows user, I recommend WinEdt which is a paid front-end for LaTeX. It has dictionaries for many languages and underlines in red the words which are written incorrectly. A right click on an underlined word shows alternatives for it. If you write in different languages, you can also combine different dictionaries.
If you problem is hyphenation, however, remember to configure MiKTeX and your document for the language considered. There may be problems still, but you can correct them manually with
A second option that some of my colleagues practice is to copy'n'paste the pdf output to Word. This may sound cumbersome and probably is, but the time you will/should take to proof read your document will exceed the time amount for the copy and paste by order of magnitudes.
- Ignores the contents of commands which don't print, for example the contents of
\labels and cite commands, which hunspell spuriously raises as possible spelling errors. You can also add commands whose contents will be ignored.
The ability to add words to the dictionary on a document-by-document basis, by adding
% add_to_dictionary: stackexchangeto the preamble.
The ability to fail on certain words, to maintain consistency
% stop_if_present: organize
The ability to detect acronyms and add them automatically to the dictionary, so the following will pass.
The Quebec Xylophone Enterprise Foundation (QXEF) is fictional.
Author names in the bibliography are automatically added (with a note).
Valid English contractions are not considered spelling errors.
The contents of
\includefiles are checked recursively.
Due to an oversight, I check against the
en_GB dictionary and don't provide the user to select a dictionary. In the next version, I'll allow any hunspell dictionary. (It's trivial to update this: just don't want to pester CRAN.)
As it hasn't been mentioned, note also Texmaker:
Cross-platform (on Linux I use 4.1.1 as it is the last static build available for download, otherwise my OS is too old), apparently it has it's own spell-check dictionaries (program directory contains e.g.
en_GB.dic - not sure if these use
aspell or standalone engine); comments are skipped (I like), commands are skipped (I like), filecontents with bibliography entries are skipped (surprised at this, like), math is skipped (like) -- though some packages/arguments are still checked/underlined, and
\cite arguments too (see Make spellchecker ignore contents of certain commands in TexMaker). In any case, this looks quite good to me...
As other users have advised,
aspell is a good tool to use for this problem.
However, rather than configuring
aspell's behaviour at the command line with
--rem-tex-command=<list>, etc. I'd recommend creating project-level
my_spelling files. These files are easier to manage and curate for larger projects and can also be version controlled (hopefully with the rest of your project files) and distributed with your content.
Typically, in my projects I would provision a simple shell script (
#! /bin/bash aspell -c -t *.tex --conf=./tex_conf --add-extra-dicts=./my_spelling
In this example I'm checking all files in the executed directory with a
.tex file extension. I also have a file
my_spelling in the same directory as my
.tex files. (You may organise your project as you see fit so long as you adjust the paths to
my_spelling, and the targeted
.tex files in
tex_conf is the place to add and remove tex commands for checking. An example
tex_conf may contain:
add-tex-command cref p add-tex-command captionsetup op add-tex-command begin pop add-tex-command frac pp
From the aspell documentation:
A ’p’ skips over a parameter while a ’P’ doesn’t. Similarly an ’o’ will skip over an optional parameter while an ’O’ doesn’t. The first letter on the list will apply to the first parameter, the second letter will apply to the second parameter etc
my_spelling may look like:
personal_ws-1.1 en 1 AIC Akaike autocorrelation HMC Stanislaw
Although this is an old question, here is what I have found to work well if you have access to Word. It is similar to the suggestion of espais.
pdflatex the document and then open the PDF in Word (which Word 2013 can do).
When proof-reading a document what I am looking for are not just spelling mistakes but more broadly typos; for example repeated words (e.g., "the the"). Word is actually quite good at catching these mistakes.
The only minor problem I have found is that certain types of formatting can confuse Word's conversion from PDF. For instance watermarks caused problems (but in my case they were easy to turn off).
It seems that the best tool on the market is GNU aspell and it supports TeX. However, it's very difficult to configure it right. I made my own texsc tool to simplify the usage of aspell. You just do this and your LaTeX documents will be checked:
gem install texsc texsc --ignore=citet,citep,verbatim book.tex chapter1.tex chapter2.tex
You can also specify your own additional vocabulary:
texsc --pws=vocab.pws book.tex
More info in this blog post of mine.
:set spell spelllang=en_us
To turn it off
For additional documentation, search for the
spell.txt file. On my Mac (OSX 10.15.7), it is located at
/usr/share/vim/vim81//doc/spell.txt. Look in
/usr/share/vim//vim81/spell for available languages.