4

The example shows that when I use the zref-perpage package, the equation numbers are reset (start at 1) when entering an align environment. The perpage package doesn't have this problem.

\documentclass{article}
\usepackage{amsmath}
\usepackage{zref-perpage}
\zmakeperpage{equation}
\renewcommand{\theequation}{\thezpage.\arabic{equation}}
\begin{document}
Equation:
\begin{equation}
  1<2
\end{equation}


Align:
\begin{align}
  2&<3\\
  &<4
\end{align}


Equation:
\begin{equation}
  4<5
\end{equation}


Align:
\begin{align}
  5&<6\\
  &<7
\end{align}


Equation:
\begin{equation}
  7<8
\end{equation}

\end{document} 
4

zref-perpage gets confused because the material in align is processed twice. A simple patch fixes the issue: stepping the internal counter only in the non-measuring phase.

\documentclass{article}
\usepackage{amsmath}
\usepackage{zref-perpage}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\ZREF@@perpage@step}
 {\global\advance\c@zref@unique\ltx@one}
 {\ifmeasuring@\else\global\advance\c@zref@unique\ltx@one\fi}
 {}{}
\makeatother

\zmakeperpage{equation}
\renewcommand{\theequation}{\thezpage.\arabic{equation}}
\begin{document}
Equation:
\begin{equation}
  1<2
\end{equation}


Align:
\begin{align}
  2&<3\\
  &<4
\end{align}


Equation:
\begin{equation}
  4<5
\end{equation}


Align:
\begin{align}
  5&<6\\
  &<7
\end{align}


Equation:
\begin{equation}
  7<8
\end{equation}

\end{document} 

enter image description here

| improve this answer | |

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.