83

I normally use my gedit spell check extension for the task, but wouldn't it be much better if you could fix any typos or otherwise during compilation time, in a sort of interactive mode?

  • 4
    Related/Duplicate Question: spell checking latex documents – Peter Grill Jan 30 '12 at 20:34
  • 2
    @PeterGrill Related, yes. Duplicate, NO. I want a package in LaTeX, not a tool in my editor. – Ayman Elmasry Jan 30 '12 at 20:37
  • 3
    The problem with an interactive mode is that the typos will still be in the source, so you'd have to do it for every run – Joseph Wright Jan 30 '12 at 20:40
  • @JosephWright Yes I suppose you're correct, you'd have to save before or after compiling. – Ayman Elmasry Jan 30 '12 at 20:54
  • 1
    @JosephWright By using aspell or ispell as I describe in my answer the spell checked file is automatically saved before compilation. – N.N. Jan 30 '12 at 20:56
26

You can let TeX (rather luaTeX) do the spell checking for you! For example, in ConTeXt MkIV, you can use

\loadspellchecklist[en][wordlist.txt]
\setupspellchecking[state=start]

where en is the current language (you can set different word lists for different languages), and wordlist.txt is a sorted list of correct words. For a complete example, see the ConTeXt wiki

  • Perfect, I'll definitely give it a try. – Ayman Elmasry Jan 31 '12 at 20:36
  • 34
    what does it do if a spelling error is found? – alfC Sep 10 '12 at 10:03
  • 2
    Strange that the above question was not answered by any one for almost 2 years. So, what does it do if it finds a spelling error? does one have to try it to find out? – Nasser Jul 11 '14 at 3:31
  • 4
    @Nasser or look at the example on context wiki (linked in the question). Any misspelled word is colored red. – Aditya Jul 19 '14 at 15:14
94

It seems unreasonable to implement spell checking as a LaTeX package when there are excellent spell checkers for the terminal that can be incorporated into the compilation process. Before you compile you can do

aspell -t -c file.tex

or

ispell -t file.tex

Either lets you interactively spell check the whole file. The -t option is to tell the spell checker that the file is in TeX or LaTeX format so that it will ignore macros.

To combine this with the compilation process you can invoke them after each other such as

aspell -t -c file.tex && pdflatex file.tex

or you could make an alias to shorten the command you need to write. If you use latexmk you could make it run aspell or ispell for each compilation by a using a technique similar to what is described in https://tex.stackexchange.com/a/42166/5701.

If you prefer to simply get a list of misspelled words non-interactively, you can run:

cat file.tex | aspell list -t | sort | uniq
  • 1
    This is not exactly what I had in mind, but according to Joseph's comment, I suppose it is not logical either, unless you can modify and save a file during LaTeX compile. – Ayman Elmasry Jan 30 '12 at 20:58
  • 1
    @AymanElmasry Why would you want to implement it as a package? Is there are reason except for want of abstraction? In case you make it only for abstraction I see no reason to implement it as package when there are excellent terminal spell checkers already. If you make an alias or implement it via latexmk you would only need to write a short command such as spellpdflatex file.tex or latexmk -r spellcheck file.tex to spell check and compile. – N.N. Jan 30 '12 at 21:02
  • 2
    @N.N You don't understand his question. He wants to fix typos during the compilation time as soon as they are start popping up in the log file. The only people who can answer this questions are pdfTeX developers. That doesn't exist and I am not sure even if it can be implemented. My best guess that is not theoretically possible to implement. – Predrag Punosevac Jan 31 '12 at 3:50
  • 2
    Just for completeness' sake, there is another command line spell check program called hunspell. It can be invoked like hunspell -t file.tex It will go through each misspelled word one at a time interactively, unless you add the -l flag, in which case it will just list all occurrences on stdout. – gla3dr Nov 21 '14 at 20:58
  • 1
    What does the -c do? I checked the manual: -c|check <file> to check a file and -t,--mode=tex enter TeX mode. Mac users with homebrew installed and with or without admin rights can do brew install aspell. Is there a way to make it ignore stuff inside for example \url{} and \graphicspath{}? I found my answer here: tex.stackexchange.com/questions/34628/… Just add --add-tex-command="graphicspath op" to the command line or modify ~/.aspell.conf as per one of the answers. – tommy.carstensen Nov 17 '17 at 12:43
9

Not an interactive solution, but you might want to have a look at the spelling package. The package requires the LuaTeX engine. Only the LaTeX format is supported, but support for other formats shouldn't be too hard to implement. Contributions are welcome!

4

If you use sublime text as an editor, you could try https://github.com/vaisaghvt/CheckTypos package.

  • 1
    Welcome to TeX.sx! Feel free to visit our TeX.SX starter guide to get the most out of this site. – Peter Jansson May 19 '13 at 9:12
  • That GitHub page specifically reads: "This plugin does not check for spelling mistakes." – tommy.carstensen Nov 17 '17 at 12:30
2

Not professional but still as an option: if one has Microsoft Word on the system, one could copy and paste the LaTeX source into Word, and following the red lines to correct them.

  • one could also use the built-in grammar check of the latest IDE. after 4 years lot has changed. – naphaneal Nov 7 '16 at 17:17
0

TexStudio does spellchecking and underlines misspelled words. It also has a spell checking menu option. No need to compile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.