# How I manage two counters for a page

I need to number the pages of an article from 1 to n inside the article (named here artpage), but also the pages included in a volume.

\newcounter{artpage}
\setcounter{artpage}{1}
\stepcounter{artpage}

%Redefine plain style to include standard RRP headers:
\if@twoside
%replace (c) with \copyright when needed!
\vbox{\hbox to \textwidth{\rmfamily\footnotesize%
\rule[-1mm]{\textwidth}{0.4pt}%
}}%

\vbox{\hbox to \textwidth{\rmfamily\footnotesize%
\thepage\hfill%
\hfill\llap{\theartpage}}%
\rule[-1mm]{\textwidth}{0.5pt}%
}}%
%
\let\@evenfoot\@oddfoot%
%
}


The artpage does not advance.

-
–  Claudio Fiandrino Jan 23 '13 at 18:40

In your code there is nothing that steps your counter (other than the \stepcounter at the very top which is executed once). So not surprising it doesn't change.

A simple solution would be to move the stepping into both \@oddhead and \@evenhead, e.g.,

\newcommand{\ps@headings}{%
%replace (c) with \copyright when needed!
\stepcounter{artpage}%
\vbox{\hbox to \textwidth{\rmfamily\footnotesize%
\rule[-1mm]{\textwidth}{0.4pt}%
}}%
%   <--- do not put an empty line into this macro
\stepcounter{artpage}%
\vbox{\hbox to \textwidth{\rmfamily\footnotesize%
\thepage\hfill%
\hfill\llap{\theartpage}}%
\rule[-1mm]{\textwidth}{0.5pt}%
}}%
%
\let\@evenfoot\@oddfoot%
%
}


Then at the beginning of each article you issue

\setcounter{artpage}{0}


0 because it is stepped when the page is made before it is used there. Of course the stepping could be done after it is used in the heading, then you would start with 1.

-
Thanks! It worked. –  Cristiana Dumitrache Jan 23 '13 at 22:02
If this provides a solution for you you might want to check mark it to indicate this. –  Frank Mittelbach Jan 23 '13 at 22:11

Sounds like you need to create a new counter that works in tandem with the current page. So if the first page of the article is on page 35 of the journal

\documentclass{article}
\usepackage{lipsum}
\newcounter{journalpage}\setcounter{journalpage}{35}
\usepackage{fancyhdr}\pagestyle{fancy}
\rhead{Article Page=\thepage\ Journal Page=\thejournalpage\stepcounter{journalpage}}
\begin{document}
\lipsum[1-150]

\end{document}

-