This is a mobile version, full one is here.

Yegor Bugayenko
6 October 2020

Spell Check Your LaTeX Writings Using GNU Aspell

Do you use LaTeX for your academic and technical writings? You don’t? Well you should! It’s the most only professional instrument for making properly formatted PDF documents. MS Word and Apple Pages are for secretaries non-tech people, while LaTeX is serious. It’s perfect in so many ways, thanks to Donald Knuth (the creator of TeX) and Leslie Lamport (the author of LaTeX), but it lacks one very convenient feature: spell checking. The only solution I’ve found so far, which works perfectly for my documents, is GNU aspell.

GNU aspell is a command line tool which expects you to provide the LaTeX source code (indeed, it is code, not “text”) as an input and prints a list of found spelling errors. The beauty of it is that it checks only the text, ignoring TeX commands. For example, this is LaTeX document:

Hello, \textbf{Yegor}!

If we feed this text to some other spell checker (or GNU aspell without the option --mode=tex) the word textbf would be an obvious spelling mistake; aspell, however, understands it as a LaTeX command and ignores it. Moreover, aspell can understand the word Yegor, even though it’s not an English word, by using a custom dictionary provided by the --pws option.

There are a few other useful features in aspell. Long story short, I decided to create a small wrapper around aspell, to simplify the process of its configuration: texsc (stands for “TeX Spell Checking”). It’s a command line tool, which you install and then run, for example like this (you can see how it’s configured in the Makefile of this paper):

$ texsc --pws aspell.en.pws --ignore=code,citep article.tex

There is a list of arguments you can supply to texsc:

I use texsc in all my LaTeX projects, usually as part of their build cycle, which I automate with GNU make. You can do the same, as it’s open source.