Sometimes I use software to generate Latex which does not support breqn package. It can create equation environment.
Is it possible to add some code, in the preamble only, which converts any \begin{equation}...\end{equation} to dmath environment?
The problem is when there is a \tag{number} at the end of the equation. Otherwise, using \renewenvironment would work.
Here is a MWE
\documentclass[12pt,notitlepage]{article}
\usepackage{amsmath}
\usepackage{breqn}
\renewenvironment{equation}{\begin{dmath}}{\end{dmath}}
\begin{document}
\begin{equation}
-\eta\omega_{y}+\left( -3y' \xi_{y}-2\xi_{x}+\eta_{y}\right)
\omega-\xi\omega_{x}+\left( -y' \eta_{y}+\left( y'\right)
^{2}\xi_{y}+y' \xi_{x}-\eta_{x}\right) \omega_{y'}+\eta
{xx}+\eta{yy}\left( y' \right) ^{2}-
\xi_{yy}\left( y' \right)^{3}-2\xi_{yx}\left( y'\right) ^{2}+2\eta_{yx}y'-\xi_{xx} y'=0\tag{1A}
\end{equation}
\end{document}
Because of the \tag{...} there at the end, it fail to compile. (using lualatex) gives
/usr/local/texlive/2023/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
! Package amsmath Error: \tag not allowed here.
See the amsmath package documentation for explanation.
Type H <return> for immediate help.
...
l.62 ...\right) ^{2}+2\eta_{yx}y'-\xi_{xx} y'=0\tag
{1A}
?
If I remove the \tag{1A} it works and compiles giving
Since can't have \tag{} in dmath*, it has to be translated to
\begin{dmath}[number=1A]
.....
\end{dmath}
But I do not know how check for \tag{...} and generate the correct dmath.
So there are two cases: equation with no tag in it, which becomes
\begin{dmath*}
.....
\end{dmath*}
This case I can do using
\renewenvironment{equation}{\begin{dmath*}}{\end{dmath*}}
The second case is where there is a \tag{N} in the equation, then this should become
\begin{dmath}[number=N]
.....
\end{dmath}
And it is this second case which is difficult.
Is it possible to handle both cases using some code in preamble? I use lualatex and the code to use can only be added to preamble, not after \begin{document}
Any suggestions how to handle both cases? The main issue is handling \tag{}. Nothing else is generated by the software, such as \label, It only generates \tag or no \tag at the end.
The reason I need to do this, is that some equations generated are very long, and I use breqn package to break them. But the software I use does not support dmath environment. Editing the code by hand to do the changes is not an option for me.
TL 2023


equationenv to be the (not numbered)dmath*rather thandmath??? – David Carlisle Sep 23 '23 at 08:10alignanddmath. So I thought an equation without a tag, is likealign*or likedmath*, i.e. no equation number. But when I just tried it, I foundequationwith no `tag`` still generate an automatic equation number. – Nasser Sep 23 '23 at 15:40