What is the meaning of the following chktex warning in this example?

41: You ought to not use primitive TeX in LaTeX code.


      & X & Y \cr
  X & 0 & 0 \cr
  Y & 0 & 0 \cr
  } \qquad


How should I fix it? Replacing \cr with \\ does not work.

2 Answers 2


First, you should always bear in mind that ChkTeX was never meant to be (and never could be) fool-proof. You have several options.

  1. Use something besides \bordermatrix as in @egreg's answer.
  2. Use (multiple) line suppressions as in @egreg's answer.
  3. Use (a single) file suppression: % chktex-file 41 somewhere before the first use. This will turn it off entirely for this file.
  4. Turn off the warning for all files in your chktexrc file. Simply add --nowarn 41 to the CmdLine section.
  5. Remove \cr from the list of primitive commands that should be avoided.

The last is the hardest, because ChkTeX currently doesn't have a way to remove from a list, so you'll have to overwrite the list entirely with a section something like:

Primitives = {
   \above \advance \catcode \chardef \closein \closeout \copy \count
   # \cr 
   \crcr \csname \delcode \dimendef \dimen \divide
   \expandafter \font \hskip \vskip \openout

   # You might consider adding other obsolete commands which are not there by default...
   \rm \it \bf \sf \tt \em

Full Disclosure: I'm the current maintainer of ChkTeX.

  • I don't think that suggesting to globally suppress warning 41 is the answer. What I'd like to have is a situation such as in my answer, where I don't want to be warned about a usage I'm well aware of. What's needed is the ability to suppress warnings in the preamble.
    – egreg
    Feb 10, 2019 at 10:01
  • I'm not sure what you mean by "in the preamble". Is that different than #3? Do you have a suggested syntax? I'm happy to consider other ways of suppressing warnings that aren't useful, since I think false positives are very annoying. Feb 11, 2019 at 3:14
  • I mean suppressing warnings for code before \begin{document}.
    – egreg
    Feb 11, 2019 at 9:21
  • Oh, I see. Try chktex -H0. Perhaps that should be the default, but I hate to change the defaults at this point--I just put everything in my .chktexrc file. Also, thanks for taking the time to engage. Feb 12, 2019 at 1:55

I find chktex unbearable. Anyway, you can make \bordermatrix to accept \\ instead of \cr. But you have to suppress the check in two lines.

Particularly annoying is that you can, in principle, suppress a warning by adding a suitable comment, which is shown nonetheless unless you suppress all warnings of type 22. This is very silly, isn't it?

I also added an alternative to \bordermatrix.

\usepackage{blkarray} % for an alternative to \bordermatrix

\patchcmd{\bordermatrix}{\cr}{\\}{}{} % chktex 41
\patchcmd{\bordermatrix}{\cr}{\\}{}{} % chktex 41


    & X & Y \\
  X & 0 & 0 \\
  Y & 0 & 0
    & X & Y \\
  X & 0 & 0 \\
  Y & 0 & 0 \\


If I call chktex -wall -n22 juan.tex, I get no warning.

enter image description here

  • 1
    "I find chktex unbearable." Now i'm curious as to why :)
    – Lupino
    Feb 8, 2019 at 11:52
  • @Lupino See the second paragraph. ;-) Besides this, warnings should be suppressed in the preamble.
    – egreg
    Feb 8, 2019 at 11:54
  • So, if you write % chktex 41 behind a "bad" cs, chktex is fine with it, unless you tell it to suppress type-22-warnings; then it is not? Seem's legit...
    – Lupino
    Feb 8, 2019 at 12:46
  • @Lupino With just % chktex 41 the output shows Warning 22 in juan.tex line 6: Comment displayed. on one line and \patchcmd{\bordermatrix}{\cr}{\\}{}{} % chktex 41 on the following line, which defeats suppressing the warning. And one can't use chktex 22 to suppress the warning about the comment. Silly.
    – egreg
    Feb 8, 2019 at 12:49
  • 1
    Warning 22 (warning about comments, which is ridiculous in my opinion), should not be on by default. If it is, then you need to contact whoever packaged ChkTeX and tell them to fix it. If you're running with -wall, then I guess you get what you asked for. As for not being able to suppress warning 22, that's arguably a bug and you should report it if you care. Full Disclosure: I'm the current maintainer of ChkTeX. Feb 10, 2019 at 5:20

You must log in to answer this question.

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