Skip to main content

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, see (emacs)Compilation section ‘Compilation’ in The Emacs Editor), 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 (See (Flymake)Using Flymake section ‘Using Flymake’ in GNU 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 doesn’t, 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>’.