# Why the new changes to LaTeX kernel breaks zref-perpage package?

Consider the following minimal example:

\documentclass{book}
\usepackage{zref-perpage}
\zmakeperpage{footnote}
\begin{document}
\chapter{Test}
\footnote{A footnote}
\footnote{A footnote}
\newpage
\footnote{Another footnote}
\end{document}


The desired effect is that the first footnote number in each page should be 1 however whenever there is a chapter on a page, the first footnote number on that page is 2.

I believe that new changes to LaTeX kernel somehow are to blame because the zref bundle have not been updated for few years. You also can confirm that this minimal example worked perfectly by using an online LaTeX compiler like overleaf which uses TeXLive 2014.

So far, I have found that adding another

\@addtoreset{footnote}{chapter}


fixes the problem so you should have at least two of this.

So what's wrong?

• Thanks Heiko. Do you know what's wrong? – user81070 Jun 30 '15 at 5:46

The book and report class reset the counter footnote at each numbered chapter:

\@addtoreset{footnote}{chapter}


The counter is applied to two systems, which reset it, thus \zmakeperpage does not have the full control over the counter. Since you want to have the counter reset at page boundaries, the effect of \@addtoreset must be undone. Here package removefromreset helps:

\documentclass{book}

\usepackage{remreset}
\makeatletter
\@removefromreset{footnote}{chapter}
\makeatother

\usepackage{zref-perpage}
\zmakeperpage{footnote}

\begin{document}
\chapter{Test}
\footnote{A footnote}
\footnote{A footnote}
\newpage
\footnote{Another footnote}
\end{document}


The responsible change in LaTeX 2015/01/01 is the changed definition of \@stpelt. After a \@addtoreset{foo}{bar} the master counter bar is increases, the dependent counters as foo are reset. Macro \@stpelt implements the reset. The old version just sets the counter to zero:

\def\@stpelt#1{\global\csname c@#1\endcsname \z@}


The new version sets first to -1 in order to use \stepcounter:

\def\@stpelt#1{\global\csname c@#1\endcsname \m@ne\stepcounter{#1}}


• The advantage is, that counter, which depend on the dependent counter are also reset. Example:

... previous section with sections, subsections, subsubsections ...
\section % resets subsection


In the old version of \@stpelt, counter subsubsection is unchanged and has the value before \section. The new version resets the counters transitively, that means, subsubsection is also reset as part of the reset action of subsection. Now subsubsection is also reset and is 0 right after \section.

\documentclass{book}

• Other packages, which hook into \stepcounter like zref-perpage do not know, that this \stepcounter is not caused by an entity, thus zref-perpage thinks that there is a footnote at the start of the chapter, a total of four footnotes, instead of three in the MWE of the question.