Spellchecking LaTeX in MacOSX

How to spell-check a LaTeX document with specialized dictionary in TeXShop.

TeXshop makes use of the default spell-check service of OSX, and this is somewhat problematic when you’re writing \LaTeX manuscripts.   Between \LaTeX keywords and specialized vocabulary, just about every word is underlined:

What would be nice is if we can:

  1. exclude LaTeX instructions from being spell-checked, and
  2. extend the dictionary to include discipline specific vocabulary (chemistry, in my case)

I think both are possible using Anton Leuski’s cocoAspell, but the latter is less straight-forward than the former.  I tried out Excalibur as well, but the standalone spell-check just doesn’t do it for me.

Installing CocoAspell

CocoAspell (2.1) is installed with a .dmg.  After installation, you’ll find an extra icon (A) under System Preferences:

It requires a reload of the system preference pane to open, after which dictionaries can be chosen:

The language selection pane (A) let you choose from the list of dictionaries that come installed with cocoAspell, and you can use multiple of them.  Filter check-boxes (B) let you decide what should not be spell-checked.  When the TeX/LaTeX box is checked (as seen in the figure), the LaTeX instructions should no longer be underlined…

It’s easier to notice mistakes now.  A note here: if installing cocoAspell does not seem to have any effect, check that TeXshop (or other applications; cocoAspell is a system-wide service) are indeed using aSpell as the checker.  You can do this through Edit -> Show Spelling and Grammar.  The default is “automatically select language”, which means aSpell is installed but not used.

Creating and Installing a Specialized Dictionary (no go?)

With LaTeX syntax no longer highlighted as mistakes, the battle is half won.  What we need is an add-on dictionary that has the vocabulary from the specialized discipline.  This turned out rather non-trivial, and I still have no idea how this is done after hacking away for hours.

I started with the very nice chemistry dictionary word-list.  Direct insertion into the personal word list doesn’t seem to work**, so the task becomes one of converting the plain-text word-list into a .rws that ASpell takes in (through .multi).  CocoAspell, however, have tangled config files in multiple directories under both usr/local/lib and ~/Library/.  What it uses seem to have no relationship with what the command line ASpell reports, and dictionary creation (following ASpell manual) was a no go.

I uninstalled cocoAspell to the best of my ability (there is no installer, and again, the files were scattered all over the place), and installed GNU Aspell using MacPorts.  This time things are at the right place, and the command line to create dictionary found all the right files to work… but it just hangs there.  If you know how to resolve this, give me a shout.

** Direct insertion into the personal word list (found in ~/Library/Preferences/cocoAspell/en.pws) works when small number of words are inserted.  However, when a large number of words (110k) are inserted, the entire spell-check function collapses.

About these ads

3 thoughts on “Spellchecking LaTeX in MacOSX

  1. Pingback: Writing Chemistry with LaTeX (1/3) « Toeholds

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s