Interesting how can I enable lacheck?
How can you afford NOT to read the AucTeX
manual? Make it a habit to read the manual when you are relying on some tool very heavily
Check for syntax errors in tex
buffers using lacheck
and flymake

(info "(auctex) Checking")
File: auctex.info, Node: Checking, Next: Control, Prev: Debugging, Up: Processing
4.4 Checking for problems
Running TeX or LaTeX will only find regular errors in the document, not examples of bad style. Furthermore, description of the errors may often be confusing. The utilities lacheck
and chktex
can be used to find style errors, such as forgetting to escape the space after an abbreviation or using ...
instead of \ldots
and other similar problems. You start lacheck
with C-c C-c Check <RET>
and chktex
with C-c C-c ChkTeX <RET>
. The result will be a list of errors in the *compilation*
buffer. You can go through the errors with C-x \`` (
next-error`, note (emacs)Compilation::), which will move point to the location of the next error.
Alternatively, you may want in-buffer notation. AUCTeX provides support for this using the Flymake package in Emacs 26 or newer (note (Flymake)Using Flymake:: for details). To enable, call M-x flymake-mode <RET>
in the buffer or enable it in all buffers by adding this to your init file:
(add-hook `LaTeX-mode-hook #`flymake-mode)
Note that AUCTeX currently only provides support for using chktex
as the flymake backend.
Each of the two utilities lacheck
and chktex
will find some errors the other doesnot, but chktex
is more configurable, allowing you to create your own errors. You may need to install the programs before using them.
You can get lacheck
from URL:https://www.ctan.org/pkg/lacheck and chktex
from URL:https://www.ctan.org/pkg/chktex. TeX Live contains both.
~$ apt-cache show lacheck
Package: lacheck
Version: 1.26-17
Installed-Size: 76
Maintainer: Davide G. M. Salvetti salve@debian.org
Architecture: amd64
Replaces: auctex (<< 9.7l-1)
Depends: libc6 (>= 2.14)
Recommends: texlive-latex-base
Suggests: auctex
Breaks: auctex (<< 9.7l-1)
Description-en:
Simple syntax checker for LaTeX
LaCheck is a simple syntax checker for LaTex that is based on a single-pass lexical scanner. This makes clear that there are a lot of LaTeX problems this program cannot find, although it will find most simple mistakes. Complex macro packages may, however, make it completely unusable. . This program was bundled with AUCTeX once upon a time and is best known from there.
~$ apt-cache show chktex
Package: chktex
Version: 1.7.6-5
Installed-Size: 225
Maintainer: Thorsten Alteholz debian@alteholz.de
Architecture: amd64
Depends: libc6 (>= 2.33), libpcre2-posix3 (>= 10.34), libtinfo6 (>= 6)
Description-en:
Finds typographic errors in LaTeX
ChkTeX finds typographic errors in LaTeX documents:
Supports over 40 warnings.
Supports \input
command; both TeX and LaTeX version. Actually includes the files. TEXINPUTS''
-equivalent search path.
Intelligent warning/error handling. The user may promote/mute warnings to suit his preferences. You may also mute warnings in the header of a file; thus killing much unwanted garbage.
Supports both LaTeX 2.09 and LaTeX2e.
Flexible output handling. Has some predefined formats and lets the user specify his own format. Uses a printf()
similar syntax. lacheck
compatible mode included for interfacing with the AUC-TeX Emacs mode.