# tex4ht gives !Package amsmath Error: \tag not allowed here

This might be an known limitation in tex4ht, I do not know. But this MWE below gives the error

! Package amsmath Error: \tag not allowed here.


Only when run with make4ht. No error with lualatex nor with pdflatex.

\documentclass[11pt]{article}
\usepackage{amsmath}

\begin{document}
$x=y \tag{1}$
\end{document}


The output is

>make4ht  foo.tex
.....
LaTeX2e <2017/01/01> patch level 3
Babel <3.9r> and hyphenation patterns for 83 language(s) loaded.
(./foo.tex (/usr/local/texlive/2016/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/size11.clo))
....
(/usr/local/texlive/2016/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2016/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(/usr/local/texlive/2016/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2016/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(./foo.aux)

! Package amsmath Error: \tag not allowed here.

See the amsmath package documentation for explanation.
Type  H <return>  for immediate help.
...
l.7 x=y \tag
{1}
?


List files

*File List*
article.cls    2014/09/29 v1.4h Standard LaTeX document class
size11.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
amsmath.sty    2016/11/05 v2.16a AMS math features
amstext.sty    2000/06/29 v2.01 AMS text
amsgen.sty    1999/11/30 v2.0 generic functions
amsbsy.sty    1999/11/29 v1.2d Bold Symbols
amsopn.sty    2016/03/08 v2.02 operator names


Version

which make4ht
/usr/local/texlive/2016/texmf-dist/scripts/make4ht/make4ht


Is the above known issue with make4ht? What should I do to workaround this? Do I need to change $..$ to \begin{align}....\end{align} to use \tag{} with tex4ht? No error there with make4ht. Only error when using tag with $..$

• Generally, $...$ used for the unnumbered display equation, may be the error due to that tag, as you suggested, change the same to align environment then check the same... Jul 25, 2017 at 9:53
• @MadyYuvi -- please not align! single-line equations should use the equation environment. (the spacing above and below is calculated differently for equation and align.) Jul 25, 2017 at 14:36
• @MadyYuvi But for one equation I've always used $...$ and not align. Also there is no error with lualatex nor with pdflatex using tag with $...$. I've also seen tag used with $...$ by Latex experts. For example this accepted answer adding-letters-to-equation-numbers uses tag with $...$ Jul 25, 2017 at 18:10

Amsmath rededines $ and $ to produce \begin{equation*} resp. \end{equation*}. tex4ht redefines it to something different, so the \tag doesn't work here anymore. You can try the amsmath definitions yourself:

\Preamble{xhtml}

\DeclareRobustCommand{$}{\begin{equation*}} \DeclareRobustCommand{$}{\end{equation*}}
\begin{document}
\EndPreamble


This is a result:

• Why don't we update the amsmath.sty in tex4ht to include these \DeclareRobustCommand's? Jan 24, 2019 at 19:02
• @FrankScience I cannot get it to work correctly, it clashes with some options Jan 24, 2019 at 20:05