Easy spell checking with LaTeX

I love LaTeX. For those of you who have never heard of it, LaTeX is a program used to typeset documents, such as letters, papers, or books. Think of it like a word processor, but different (and imho better, being the geek i am). To use LaTeX, you write up a document with any editor you choose and place mark-up tags to specify things like bold, center, or start of a new section. If you have ever written even dirt-simple HTML, you will feel very comfortable with LaTeX. Once you have written your document, you run the LaTeX program on it and viola - a beautifully formatted document in PDF or Postscript is produced. LaTeX is free, open source, and runs on every operating system ever invented. If you are using Unix/Linux, it is probably already installed. If you are using Windows, grab a great distribution of LaTeX from http://www.miktex.org.

When it comes time to spell check your work, however, you have a problem. Similar to spell checking HTML source, you need a program that can spell check your document contents but not the document mark-up tags. Most LaTeX aficionados suggest using ispell or aspell. While these tools indeed work, they are old, cruddy, and don't work well on Windows. I have found a few better alternatives:

  • Use the spell checker built into Vim. If you are already using the popular Vim editor, did you realize that Vim versions 7.x and above can check your spelling in LaTeX as you write? Just like MS Word, Vim will place a red line under misspelled words. You can then write click for suggestions, or add the word to your custom dictionary. Use gvim (the Vim GUI) for best ease of use. Assuming you already have vim performing syntax highlighting of your LaTeX document, just add the following to your ~/.vimrc (on Unix) or your ~/_vimrc (on Windows) :
autocmd FileType tex setlocal spell spelllang=en_us

Now whenever you open a .tex file, Vim will real-time check your content and ignore your mark-up tags, just like you want.
  • Use the spell checker built into Emacs. So, you are an Emacs weenie, eh? Real men use vi, ya know. Eh, no worries, you Emacs sissies can activate LaTeX spell checking by adding the following to your .emacs file:
(add-hook 'tex-mode-hook (lambda()(flyspell-mode 1)))

  • Use 4spell on Windows. If you are working on Windows, yet another option is to use the free Windows program 4spell. It understands plain ASCII, TeX, RTF, HTML and BibTeX. While I certainly wouldn't call it modern, it is a hell of a lot nicer than ispell - see the screenshot on the right.

1 comment:

Anonymous said...

Real women use vi too :)