Cleveref has a useful feature in \crefformat where an equation can be referred to, for instance, an inequality. This adds an extra square-bracket argument to the \label command. For example:


    S \leq 2.

However, when using chktex for syntax validation there are two spurious syntax warnings. First, it points to the closing square bracket on the \label line saying

Solo `]' found.

and secondly, on the final line of the document it says

Number of `[' doesn’t match the number of ']'.

I do not simply want to turn these warnings off as I believe there is some underlying explanation for these warnings.


Create a file called something like mychktexrc somewhere, containing

    \label:[]{} \ref:{} \eqref:{} \vref:{} \pageref:{} \index:[]{}
    \cite:[][]{} \nocite:{}
    \input:{} \verbatiminput:[]{} \listinginput:[]{}{}
    \verbatimtabinput:[]{} \include:{} \includeonly:{}
    \cline:{} \cmidrule:[](){}
    # Cleveref -- there are many others that could be here as well...
    \cref:*{} \cpageref:*{} \crefrange:*{}{} \cpagerefrange:*{}{}
    \Cref:*{} \Cpageref:*{} \Crefrange:*{}{} \Cpagerefrange:*{}{}
    # natbib
    \citet:*[][]{} \citep:*[][]{} \citealt:*{} \citealp:*[]{} \citeauthor:*{}
    \Citet:*[][]{} \Citep:*[][]{} \Citealt:*{} \Citealp:*[]{} \Citeauthor:{}
    \citetext:{} \citeyear:*{} \citeyearpar:{}
    # tipa which uses "

which is the same entry as in the default chktexrc file, but with \label marked to accept an optional argument.

Then running

chktex -l mychktexrc filename

you shouldn't get any error message.

The argument for the -l command line option should have the path for the created file.

  • I created a new file ´~/.chktexrc´ with the contents specified. In order to get the vim syntastic plugin to use this rc file I added the following to my .vimrc: let g:syntastic_tex_chktex_args = ("-l \"".$HOME."\\.chktexrc\"") – Jonathan Jogenfors Jul 16 '17 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.