[Tex/LaTex] Spell checking in Shell

spellingtools

I know I can use TeXShop or any other word processing program to spell check my document, but I was wondering, if there are any spell checking scripts, which run in a shell/Terminal.

I saw that there is a program called aspell, but it hasn't been updated for a long time. Are there any good programs/scrips out there?

Best Answer

aspell

Although aspell has been mentioned, I would like to give some usage examples.

Basic usage

aspell --mode=tex -c sample-file.tex

Languages

List all dictionaries:

aspell dump dicts

Change language to check:

aspell --lang=de --mode=tex -c sample-file.tex

Downsides of aspell

The following is from a German document I've just written. It has 413 lines, so it is rather small.

This should have been recognized as LaTeX, but wasn't:

Before \begin{document}:

  • \sisetup{locale=DE} - "locale"
  • \pgfmathdeclarefunction{strrepeat}{2}{% - "strrepeat"
    • pgfmathint{#2}\pgfmath@count\pgfmathresult and twice later - 3x"count"
    • \let\pgfmathresult\pgfutil@empty - "empty"
    • \pgfutil@loop - "loop"
    • \pgfutil@repeat - "repeat"
  • \pgfmath@smuggleone - "smuggleone"
  • \algtext*{EndIf} - "EndIf", "EndWhile", "EndFunction"
  • \usetikzlibrary{arrows, positioning, calc, shapes} - "arrows", "positioning", "calc", "shapes"
  • \DeclareMathOperator{\ggT}{ggT} - "ggT" (That is valid in a German document about math)

25x words in:

\tikzset{
  Stern Brocot at/.style={at/.pgfmath={
      strcat("([rotate around=180:(!", strrepeat("#1",\SBLevel),")] !",
                                       strrepeat("#1",\SBLevel-1),"2)")}},
  Stern Brocot at*/.style n args={3}{
    at/.pgfmath={strcat("(!",strrepeat("#1",#2),"-| SB@#3)")},
    append after command/.expanded={\ifnum#2<\SBLevel(\noexpand\tikzlastnode)
      edge[densely dotted] (SB@#3@\the\numexpr\SBLLoop+1\relax)\fi}}}

After \begin{document}:

  • Almost everything within TikZ
  • Much in algorithm environment
  • \begin{tabular}{l||ccl} - "ccl"

aspell also has problems with hyphenated words (source)

Workarounds

Create a file called my_def.tex and put your whole preamble in it. Then add \include{my_def} to your preamble. It should be your file in there.

However, this does not solve the TikZ / table issue. But you can apply the same workaround for TikZ images. I guess it is not convenient to do so for tables.