Open kia999 opened 4 years ago
Yes. But I don't think that zref can do much here. The amsmath environments take a lot trouble to save and restore \label when processing the content but ignore \zlabel. So amsmath would need a change.
You can get your example more or less working with the following. But it could have bad side effects if you have \label commands in other places:
\documentclass[a4paper]{article}
\usepackage[user]{zref}
\makeatletter \def\label{\zref@wrapper@babel\zref@label}\makeatother
\usepackage{amsmath}
\begin{document}
\begin{equation}
\zlabel{eq:01}
E=mc^{2}
\end{equation}
\begin{multline}
\label{eq:02}
W = \int \vec{\xi}\cdot \vec{F}(\vec{\xi}) \,d^{3}x
=
\\
\iint \ldots
\end{multline}
First Eq.~\zref{eq:01}, second Eq.~\zref{eq:02}.
\end{document}
@u-fischer : No, it does not work.
Yes, it does. I tested it on a current texlive.
@kia999 your last comment appears scrambled (it just shows as CSS?) could you clarify your "not work" comment by showing the log, or saying what happens?
@kia999 Works fine for me on miktex too.
In my example zref is loaded after amsmath, and \zref prints ?? if \zlabel is inside multline. Log file reports that label is not found.
In example given bu Ulrike Fischer zref goes before amsmath and \zref works fine.
@u-fischer I suppose it might be possible for \zlabel
to check if \label
is \label@in@display
(that is check if it's in the scope of a local amsmath alignment redefinition of \label
) and if so adapt itself accordingly, perhaps...
@davidcarlisle the problem isn't so much that zlabel isn't executed, but that even if one force the execution it doesn't get the right values to save them to the aux file. E.g.
\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage[user]{zref}
\begin{document}
\makeatletter
\renewcommand*\zlabel{%
\zref@wrapper@babel\zref@label
}%
\begin{multline}
%\def\@currentlabel{\theequation}
\zlabel{eq:02}
W
\end{multline}
Eq.~\zref{eq:02}.
\end{document}
without the \@currentlabel
definition the default is empty \default{}
, and with it it is 0.
I noted that \zlabel is ignored inside multline environment, it does not write \zref@newlabel to aux file. Here is MWE: