Thursday, March 4, 2010

Spell Checker, LaTeX, and OS X

Spell checking is a standard feature today. With LaTeX however it is not too easy to achieve. You can certainly use the build-in spell checker of OS X, but then you have to "proof read" all LaTeX commands and their parameters, which can be annoying. So I was looking for a better solution.

Because it was automatically installed I tried Excalibur. Frankly, I don't like it at all, but maybe I have missed something. It only offers very limited options. Unfortunately it doesn't support UTF-8. Since I'm using XeTeX wiht UTF-8, a spell checker w/o UTF-8 support is useless for me.

So I tried Aspell. If you look at the Aspell webpage, you'll get this "Linux users have to compile their application" feeling. There is a darwin port of aspell triggering a "Darwin users have to compile their application" feeling...

Fortunately, I eventually found CocoAspell. (Yes, well, there's a link to it on the TeXShop website ;-) ...) It comes with an installer, so you don't have to install XCode or Fink :-D. Best of all, it installs a system preference panel -- and that's really great! With this filter shown in the screenshot you can define LaTeX commands and if their arguments are to be spell checked. For example, the argument of \section{} is to be spell checked, while labels (\label{} ) are not to be spell checked. It comes with a list of predefined commands, and I added some commands, e.g., \autoref{} (as you can see in the screenshot).

You can find dictionaries at, before downloading them read the hints at cocoAspell's webpage.

I had some problems activating the Aspell dictionaries in TeXShop. Of course, you have to activate the dictionary in cocoAspell's prefernce panel. And I had to deactivate the "check spelling" box in the TeXShop preference, I don't know why. Spell checking is activated in TeXShops edit menu, I don't know what this preference setting is good for...

Well, spell checking a document for the first time usually means to add a lot of word to the dictionary. Sometimes, you want to edit this user dictionary (maybe because you added a word by mistake of because you want to add an existing list). The user dictionaries can be found at ~/Library/Spelling. These files are simple text files and you can open and edit these files with almost any editor. However, the words are separated with an usually invisible character, so you have to use an editor which can show invisible characters, such as SubEthaEdit (unfortunately, TeXShop cannot show these characters).

OK, now that we have a nice spell checker for LaTeX, we only have to change the language in "Spelling and Grammar". However, opening that tiny window requires a bunch of mouse clicks, and often we do not want to actually spell check but only change the dictionary. I found a small applescript at maxoxhints forum, and the version provided by Eponymous works for me. Eponymous' script could be added to the apple script menu and then will be available in all applications. Note: In order to make this script work, you have to activate "Enable access for assistive devices" in the "Universal Access" panel of the system preferences.

1 comment:

mrcc said...

Thanks a lot for the post. I hope cocoAspell will work well.