2

I try to compile the following very simple code by tex4eboot:

\documentclass{amsart}

\begin{document}
\[
  x=y\label{t1}\tag{Test}
\]
Look at equation \ref{t1}.
\end{document}

It gives me errors:

[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ./test.tex   5    Package amsmath Error: \tag not allowed here.
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ./test.tex   5    Package amsmath Error: \tag not allowed here.
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ./test.tex   5    Package amsmath Error: \tag not allowed here.

However, I can use pdflatex to compile it. I know that I can replace \[ and \] by equation. However, since usually the article is long and a regexpr to replace will lead to unexpected results. I wonder a workaround for this. Thanks!

  • 1
    if you get an error please always show the exact error from the log, I get no error with pdflatex (as you say) – David Carlisle Dec 13 '19 at 23:31
1

Try the following configuration file:

\Preamble{xhtml}
\Configure{[]}{\begin{equation*}}{\end{equation*}}{}
\begin{document}
\EndPreamble

It basically does the same thing as Amsmath, configures \[ ... \] to the equation* environment.

This is the result:

enter image description here

I've added this code to tex4ht sources, so it should be default behavior in the future.

| improve this answer | |
  • Thanks. I found that in my configure file, it has a previous configuration like RobustCommand to treat \[ as \begin{equation*}. Unfortunately, I deleted it so I cannot recover it now. What's the different between the two? – Yai0Phah Dec 16 '19 at 9:00
  • @Yai0Phah the \RobustCommand version could broke some things, it don't work for MathML for example. This version should be safer. – michal.h21 Dec 16 '19 at 9:22
0

Generally \[...\] used for unnumbered display equation, if you change your code to \begin{equation}...\end{equation}, then your code works fine, and the modified MWE is:

\documentclass{amsart}

\begin{document}
\begin{equation}
  x=y\label{t1}\tag{Test}
\end{equation}
Look at equation \ref{t1}.
\end{document}

and the converted HTML output is:

enter image description here

| improve this answer | |
  • It is very weird that equation* works but \[ and \] don't work (I found it just after upgrade to the current version of tex4ht, previously equation* did not work). I know that equation always works, but since \[ and \] work for pdflatex, I hope that it would be supported in tex4ht. – Yai0Phah Dec 14 '19 at 17:19
  • michal.h21 already answered that he added this code to tex4ht sources... – MadyYuvi Dec 16 '19 at 5:00

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.