3

My aspell version.

aspell --version
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.7-20110707)

The simple tex file.

cat  /tmp/test.tex
\documentclass{article}
\title{First \LaTeX Document}
\begunn{document} 
\maketitle 
Hello, \LaTeX! 
\end{document}

You can see that word begunn in the test.tex file is wrong spell.

Now to check it with aspell command.

aspell --lang=en --mode=tex check  /tmp/test.tex

Nothing as output for the aspell command,why ?

4
  • 3
    --mode=tex means that it skips macro names.
    – campa
    Commented Mar 21, 2018 at 9:04
  • Nothing as output for aspell --lang=en check /tmp/test.tex too.
    – showkey
    Commented Mar 21, 2018 at 9:29
  • 2
    Aspell automatically uses TeX-mode when checking test.tex because of its extension (.tex). If you were to rename the file to test.txt (and remove --mode=tex), then aspell would treat is as a normal text file and complain about 'documentclass', 'LaTeX', 'begunn', and 'maketitle' being misspelt, since none of these are English words. To force aspell to treat test.tex as a text file you can also use 'aspell --lang=en --mode=none check /tmp/test.tex'. Commented Mar 24, 2018 at 21:45
  • 2
    This isn't really what aspell should be used for though. A better way to find out that \begunn was misspelt is to just run (pdf)latex, which will produce an error ("! Undefined control sequence. l.3 \begunn") Commented Mar 24, 2018 at 21:49

1 Answer 1

6
+50

The manual for aspell is at http://aspell.net/man-html/index.html

Firstly, from http://aspell.net/man-html/Spellchecking-Individual-Files.html#Spellchecking-Individual-Files

If the mode option is not given, then Aspell will use the extension of the file to determine the current mode. If the extension is .tex, then tex mode will be used, if the extension is .html, .htm, .php, or .sgml it will check the file in sgml mode, otherwise it will use url mode.

http://aspell.net/man-html/Notes-on-Various-Filters-and-Filter-Modes.html#Notes-on-Various-Filters-and-Filter-Modes describes the different filter modes. These include

--mode=none

4.4.1.1 None Filter Mode

The none mode is exactly what it says. It turns off all filters.

and

--mode=tex

4.4.1.6 TeX/LaTeX Filter

The tex (all lowercase) filter mode skips over TeX commands and parameters and/or options to certain commands.

So running as you do either with --mode=tex or without a mode switch will check the parts of the file that are not macro names. In particular, on your sample file

 aspell --lang=en check test.tex 
 aspell --lang=en --mode=tex check test.tex 

both return no errors, whereas

 aspell --lang=en --mode=none check test.tex

catches all the macros including valid ones such documentclass.

Running LaTeX itself is the quickest way to check validity of names of macro constructions. On your file latex test gives

LaTeX2e <2017-04-15>
Babel <3.18> and hyphenation patterns for 84 language(s) loaded.
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/size10.clo))
! Undefined control sequence.
l.3 \begunn
           {document}
? 

indicating that \begunn is not known.

There do exist lint like programs for Latex, see Is there a program equivalent to lint for LaTeX?, which capture some incorrect constructions, but they will not tell you whether a macro name is known to LaTeX for fundamental reasons from the way the system is built up. See How to lint for undefined control sequence? for a discussion.

You must log in to answer this question.

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