104

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?

7
  • 5
    Related/Duplicate Question: spell checking latex documents Jan 30, 2012 at 20:34
  • 5
    @PeterGrill Related, yes. Duplicate, NO. I want a package in LaTeX, not a tool in my editor. Jan 30, 2012 at 20:37
  • 4
    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, 2012 at 20:40
  • What is the difference beteween aspell and ispell?
    – a06e
    Oct 11, 2017 at 10:46
  • 1
    Also: tex.ac.uk/FAQ-spell.html
    – 0 _
    Feb 9, 2018 at 23:26

11 Answers 11

34

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

3
  • 8
    @Nasser or look at the example on context wiki (linked in the question). Any misspelled word is colored red.
    – Aditya
    Jul 19, 2014 at 15:14
  • 1
    But it's possible that an inappropriate word is used, spelled correctly. No spelling-only checker will find and report that, and using one may give an unwarranted sense of security. Syntax checking (and a good proofreading) is also needed. Aug 8, 2019 at 14:00
  • 1
    @barbarabeeton: Agreed. A good (and critical) proofreading is essential.
    – Aditya
    Aug 8, 2019 at 15:15
130

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
5
  • 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, 2012 at 21:02
  • 3
    @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. Jan 31, 2012 at 3:50
  • @PredragPunosevac I do understand it but argue that it seems unreasonable to do so when there are excellent spell checkers for the terminal already.
    – N.N.
    Jan 31, 2012 at 7:21
  • 3
    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, 2014 at 20:58
  • 2
    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. Nov 17, 2017 at 12:43
10

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!

1
  • What is the possibility of expanding the scope of the spelling package to pdfLaTeX as well, for example?
    – lucenalex
    Aug 27, 2020 at 14:23
6

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.

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

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

1
  • 5
    That GitHub page specifically reads: "This plugin does not check for spelling mistakes." Nov 17, 2017 at 12:30
3

It's not the 2010s anymore...

Just use a spell check package for your favorite Integrated Development Environment.

For instance, Code Spell Checker for Visual Studio Code.

2

There is a quite nice frontend to use languagetool with latex files: TeXtidote

It marks the found correction at the corresponding position in your tex files...

1

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

0

I made my own texsc tool to simplify the usage of GNU aspell. You just do this and your LaTeX documents will be checked:

gem install texsc
texsc --ignore=citet,citep,verbatim book.tex chapter1.tex chapter2.tex

You can also specify your own additional vocabulary:

texsc --pws=vocab.pws book.tex

More info here and in this blog post.

0

In case you are using VS Code, you can install the LTeX – LanguageTool grammar/spell checkin which calls LanguageTool behind the scenes.

0

Like Gottfried William answered TeXstudio does spellchecking without needing to compile.

I will add to this that you can also download a dictionary from Open Office like https://extensions.openoffice.org/de/project/dutch-spelling-and-hyphenation-dictionary for additional langauge support, you just need to load the .oxt file inside TeXstudio.

I just set it this up and I'm satisfied with the result!

On the side you can go for Aspell like some mentioned but for me it's a hassle if you're just looking to correct spelling mistakes while typing in an edditor like TeXstudio.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .