Is there a program equivalent to lint for LaTeX? (lint checks C code for syntax errors and possible mistakes.)
5 Answers
Yes, ChkTeX
and lacheck
. (You probably already have it: if you're using AucTeX on Emacs, when you hit C-c C-c
to compile, type ChkTex
or Check
(for ChkTex
and lacheck
respectively). Or else, at the commandline, try lacheck
.) Thanks for reminding me of this; I ought to use it more (though it can be very annoying :P).
-
1It's also worth noting that if you're AucTex on Emacs you can also use m-x flyspell-mode for spell-checking. Jul 26, 2010 at 21:24
Below is a link to a package that provides style checking for latex source files.
http://www.cs.umd.edu/~nspring/software/style-check-readme.html
It will find common latex typos (e.g. " instead of ``) rather than overt syntax problems. It also comes with a set of rules to detect common grammar mistakes.
I used it (with some modifications to the style rules) on my thesis. I found it most useful to enforce my own spelling rules and standardize some latex constructions.
It's pretty easy to customize, which makes it handy; though I haven't used the other suggestions so I don't know how easy they are to customize.
-
3This seems to be more about writing style and less about LaTeX style than ChkTeX or lacheck. Not to say that it's bad, just different. In fact I think they complement each other fairly well. Mar 29, 2012 at 19:56
-
Because TeX is a markup language it doesn't suffer from things like undefined behaviour as C, so we are mostly down to detecting errors ahead of the run.
ConTeXt comes with a syntax checker script for checking mismatched braces. Unfortunately it cannot tell you about undefined control sequences because you can (re)define your own, so this is impossible to know prior to running.
\starttext
This is some text\footnote{Oops missing brace
\stoptext
$ mtxrun --script check test.mkvi
3 grouping error xt <lf> <lf> This is some text\footnote{Oops missing brace <lf> <lf> \stoptext <lf>
The nag package might be worth mentioning in this context:
Old habits die hard. All the same, there are commands, classes and packages which are outdated and superseded. The nag package provides routines to warn the user about the use of such obsolete things. As an example, we provide an extension that detects many of the “sins” described in l2tabu.