Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question originates from a bug report at SourceForge.net: biblatex from April 2010. A user pointed out that a certain biblatex style (verbose-inote) produced wrong references when used together with the pagenote package (which, quoting from its documentation, "provides notes similar to footnotes except that they are typeset on a different page"). What follows is the response of Philipp Lehman, the author of biblatex:

Looks like a bug in the pagenote package which does not seem to support \label in the pagenotes:

\documentclass{scrartcl}
\usepackage{pagenote}
\makepagenote
\begin{document}
Text\pagenote{Page note.\label{test1}}
Text\pagenote{See note \ref{test1}.}
Text\pagenote{Another page note.\label{test2}}
Text\pagenote{See note \ref{test2}.}
\printnotes
\end{document}

It works fine with the endnotes package so I suggest you try that:

\documentclass{scrartcl}
\usepackage{endnotes}
\begin{document}
Text\endnote{Endnote.\label{test1}}
Text\endnote{See note \ref{test1}.}
Text\endnote{Another endnote.\label{test2}}
Text\endnote{See note \ref{test2}.}
\theendnotes
\end{document}

The verbose-inote style uses the \label+\ref mechanism. Since this is a standard LaTeX feature, I consider this a bug in/a limitation of the pagenote package.

Recently, I took a look into endnotes.sty (which also contains the package documentation) and stumbled upon the following change note:

Modification by Dominik Wujastyk, London, 19 September 1991:

Moved the line

\edef\@currentlabel{\csname p@endnote\endcsname\@theenmark}

out of the definition of \@endnotetext and into the definition of \@doanenote so that \label and \ref commands work correctly in endnotes. Otherwise, the \label just pointed to the last section heading (or whatever) preceding the \theendnotes command.

This former bug of the endnotes package actually equates to the current behaviour of pagenote. It is unclear to me if the author of the pagenote package, Peter Wilson, did not want to include a cross-referencing mechanism or if pagenote suffers from a similar bug as endnotes once did, but for biblatex's verbose-inote style, a \label+\ref mechanism in pagenote would be extremely useful.

By now, you may have guessed the actual question: What modifications in / additions to pagenote.sty would be necessary to support the standard LaTeX cross-referencing mechanism?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

After a lot of trial and error, I'v come up with what seems to be a solution. I suspect that my approach is rather long-winded and offers room for improvement.

Rummaging through endnotes.sty and pagenote.sty, I noticed that endnotes provided for writing more data in the .ent file (an auxiliary file that contains the text of endnotes). Basically, parts of the \refstepcounter mechanism (especially \edef\@currentlabel) were "sourced out". I experimented with pagenote's single occurence of \refstepcounter in order to write data into the auxiliary file and at some point was partially successfull -- cross-references for pagenotes kind-of worked, but resetting the pagenote counter for new chapters/sections (the default behaviour without the continuous package option) was broken.

My currrent approach is to create a new counter that "mirrors" the pagenote counter. Every time the \@wrpnote macro increments the original counter, it also writes \refstepcounter{pnotemirror} into the .ent auxiliary file, and every time the value of the original counter is 0 (i.e., has been reset by a \chapter or \section command), the "mirror" counter is also reset. Clumsy, but it seems to work.

\documentclass{scrartcl}

\usepackage[%
  continuous% Default: pagenote counter is reset with new chapters/sections
]{pagenote}
\makepagenote

\usepackage{etoolbox}

\newcounter{pnotemirror}

\makeatletter
\renewcommand{\@wrpnote}[2][]{%
  \ifnumequal{\value{pagenote}}{0}% NEW
    {\@pnwrite\@notefile{}{\string\setcounter{pnotemirror}{0}}}% NEW
    {}% NEW
  \refstepcounter{pagenote}%
  \notenumintext{\thepagenote}%
  \ifpnhaschapter
    \ifnum\value{pnotesavechap}=\value{chapter}\else
      \setcounter{pnotesavechap}{\value{chapter}}%
      \addtonotes{\pagenotesubhead{\thechapter}{\f@rtoc}}%
    \fi
  \else
    \ifnum\value{pnotesavechap}=\value{section}\else
      \setcounter{pnotesavechap}{\value{section}}%
      \addtonotes{\pagenotesubhead{\thesection}{}}%
    \fi
  \fi
  \@pnwrite\@notefile{}
%     {\string\noteentry{\thepagenote}{#1}{#2}{\thepage}}% DELETED
    {\string\refstepcounter{pnotemirror}\string\noteentry{\thepagenote}{#1}{#2}{\thepage}}% NEW
  \endgroup
  \@esphack}
\makeatother

\begin{document}

\section{foo}

Text\pagenote{Page note.\label{test1}}
Text\pagenote{See note \ref{test1}.}
Text\pagenote{Another page note.\label{test2}}
Text\pagenote{See note \ref{test2}.}

\section{bar}

Text\pagenote{Page note.\label{test3}}
Text\pagenote{See note \ref{test3}.}
Text\pagenote{Another page note.\label{test4}}
Text\pagenote{See note \ref{test4}.}

\printnotes

\end{document}

EDIT: The memoir class emulates the functionality of the pagenote package and therefore suffers from the same bug. Because memoir uses different macro names, for the sake of convenience here's a "patch" for memoir (to be added in the document preamble):

\usepackage{etoolbox}

\newcounter{pnotemirror}

\makeatletter
\renewcommand{\m@m@wrpnote}[2][]{%
  \@ifmtarg{#1}{%
    \ifnumequal{\value{pagenote}}{0}%
      {\m@m@pnwrite\@notefile{}{\string\setcounter{pnotemirror}{0}}}%
      {}%
    \refstepcounter{pagenote}%
    \notenumintext{\thepagenote}}{}%
  \ifm@mpn@new@chap
    \global\m@mpn@new@chapfalse
    \addtonotes{\string\pagenotesubhead{\@chapapp}{\thechapter}{\pnchap}}%
  \fi
  \ifm@mpn@new@schap
    \global\m@mpn@new@schapfalse
    \addtonotes{\string\pagenotesubhead{\@chapapp}{}{\pnschap}}%
  \fi
  \m@m@pnwrite\@notefile{}
    {\string\refstepcounter{pnotemirror}\string\noteentry{\thepagenote}{#1}{#2}{\thepage}}%
  \endgroup
  \@esphack}
\makeatother
share|improve this answer
    
Using the memoir flavor (MWE), I get: ! Use of \\m@m@wrpnote doesn't match its definition. \protected@write ...le@protect \edef \reserved@a { \write #1{#3}}\reserved@a ... l.36 Text\pagenote{Page note.\label{test1}} –  Joe Corneli May 27 '13 at 19:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.