amsmath package error using SIAM LaTeX template files

Looks like a “feature” of ntheorem package

You can reproduce the error with

documentclass{article}
usepackage[leqno]{amsmath}

RequirePackage[amsmath,thmmarks,hyperref]{ntheorem}%[1.33] (bad use of this argument in siam class)



begin{document}
begin{equation}
bar{x} = x + y
tag{$bar{x}$}
label{eq:x}
end{equation}

end{document}

could trace exactly where it goes wrong but I’d be tempted to simply accept the other answer and use mbox workaround.

For very strange reasons, ntheorem, when used with the thmmarks and amsmath options, redefines [email protected]@@ (an internal command of amsmath) to do, among other things

settowidth{tagwidth}{$##1$}%

This is utterly wrong, because ##1 is substituted with the tag text, which is supposed to be in text mode.

Now, what happens when you do tag{$x$}? The settowidth macro puts the second argument in an hbox, so what results is hbox{$$x$$} which is legal, because $$ in restricted horizontal mode just typesets an empty math formula, and what’s measured is a text mode “x”. But $bar{x}$ (or any other inherently math), the code hbox{$$bar{x}$$} tries to typeset bar{x} in text mode, and the error is shown. Moreover, something like tag{a*} would end up to be wrongly measured, because the width of a* in text mode is quite different from the width of $a*$.

Solution: patch the relevant command to remove the nasty $ characters.

documentclass{article}
usepackage[leqno]{amsmath}
usepackage{etoolbox}

usepackage[amsmath,thmmarks,hyperref]{ntheorem}

patchcmd{SetTagPlusEndMark}{$}{}{}{}
patchcmd{SetTagPlusEndMark}{$}{}{}{}

begin{document}

begin{equation}
bar{x} = x + y
tag{$bar{x}$}
label{eq:x}
end{equation}

end{document}

enter image description here

The same works with siamart0516.cls:

documentclass[review]{siamart0516}
usepackage{amsmath}

usepackage{etoolbox}

patchcmd{SetTagPlusEndMark}{$}{}{}{}
patchcmd{SetTagPlusEndMark}{$}{}{}{}

begin{document}

begin{equation}
bar{x} = x + y
tag{$bar{x}$}
label{eq:x}
end{equation}

end{document}

If it may be an aswer only for the second part of yor question, putting into mbox seems to solve the problem:

documentclass[review]{siamart0516}
usepackage{amsmath}

begin{document}
begin{equation}
bar{x} = x + y
tag{mbox{$bar{x}$}}
label{eq:x}
end{equation}

end{document}

Leave a Comment