I have a problem with some custom-defined counters. The idea is to define the counter which will reset on each page increment and to produce labels like 1a, 3c where the number corresponds to the page number and the letter corresponds to the counter within that page. Now, a simple test like this works flawlessly:
Code: Select all
\documentclass{article}
\usepackage{hyperref}
\usepackage{fontspec}
\newcounter{chunk}[page]
\setcounter{chunk}{0}
\renewcommand\thechunk{$\arabic{page}\alph{chunk}$}
\begin{document}
Some text
{
\refstepcounter{chunk}\label{chunk: 1}
Chunk \thechunk : data
}
{
\refstepcounter{chunk}\label{chunk: 2}
Chunk \thechunk : data
}
\newpage
Some text
{
\refstepcounter{chunk}\label{chunk: 3}
Chunk \thechunk : data
}
{
\refstepcounter{chunk}\label{chunk: 4}
Chunk \thechunk : data
}
\begin{enumerate}
\item \ref{chunk: 1} at page \pageref{chunk: 1}
\item \ref{chunk: 2} at page \pageref{chunk: 2}
\item \ref{chunk: 3} at page \pageref{chunk: 3}
\item \ref{chunk: 4} at page \pageref{chunk: 4}
\end{enumerate}
\end{document}
I found some info suggesting that using \thepage might be dangerous because the page number is not always known a particular point of time. Maybe this has something to do with my problem, I have no idea how to deal with it however. I also noticed that the aux entries for labels appear differently. The "correct" file (code above) has aux labels set in form:
Code: Select all
\newlabel{chunk: 1}{{$1a$}{1}{\relax }{chunk.1.1}{}}
...
\newlabel{chunk: 1}{{$1a$}{1}{\relax }{chunk.2.1}{}}
Code: Select all
\newlabel{chunk: 1}{{$1a$}{1}{\relax }{chunk.1}{}}
...
\newlabel{chunk: 1}{{$1a$}{1}{\relax }{chunk.1}{}}
Thank you for any helpful suggestion...