zref amsmath 环境

zref amsmath 环境

这个帖子我问了一个关于zref包的具体问题。答案非常令人满意,但不幸的是,我注意到,例如,zref在某些 ams 环境中无法工作,例如multline,更具体地说:

\documentclass{book}

\usepackage{amsmath}
\usepackage{zref-user,gettitlestring}
\usepackage{hyperref}

\newcommand{\setcurrentchaptername}[1]{\GetTitleStringNonExpand{#1}\edef\currentchaptername{\detokenize\expandafter{\GetTitleStringResult}}}
\def\currentchaptername{}
\makeatletter
\zref@newprop{chapter}{\thechapter}
\zref@addprop{main}{chapter}
\zref@newprop{chaptername}{\currentchaptername}
\zref@addprop{main}{chaptername}
\ZREF@patch{@chapter}{\def\@chapter[#1]{\setcurrentchaptername{#1}%
  \ZREF@org@@chapter[{#1}]}}
\makeatother

\numberwithin{equation}{chapter}
\renewcommand{\theequation}{\arabic{equation}}

\makeatletter
\newcommand{\myref}[1]{\zrefused{#1}%
\ifnum\zref@extract{#1}{chapter}=\thechapter\relax
(\zref{#1}) \else (\zref{#1})\textsubscript{\zref@extract{#1}{chaptername}}\fi}
\makeatother

\begin{document}
\chapter{First}
\myref{eq:1}, \myref{eq:2}, \myref{eq:3}, \myref{eq:4}
\section{First First}
\begin{equation}\zlabel{eq:1}
  E=\gamma m
\end{equation}
\section{First Second}
\begin{equation}\zlabel{eq:2}
  0=0
\end{equation}
\chapter{Second}
\myref{eq:1}, \myref{eq:2}, \myref{eq:3}, \myref{eq:4}
\begin{equation}\zlabel{eq:3}
  e^{i\pi}+1=0
\end{equation}
\chapter{Third}
\myref{eq:1}, \myref{eq:2}, \myref{eq:3}, \myref{eq:4}
\begin{equation}\zlabel{eq:4}
  f(w) = \frac{1}{2i\pi}\oint_{C_w}\frac{f(z)\mathrm{d}z}{z-w}
\end{equation}
\chapter{Last}
\myref{eq:1}, \myref{eq:2}, \myref{eq:3}, \myref{eq:4}
\end{document}

运行完美,这正是我想要的,但如果我equation用 替换环境multline,它就不会编译。我知道.aux文件存在一些问题。有没有办法让zrefmultline同时工作?我知道可以multline用类似的环境替换,但我正在寻找一些在所有情况下都能很好地运行的修改过的参考系统。

相关内容