# 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
\newcommand{\ps@headings}{%
%replace (c) with \copyright when needed!
\renewcommand{\@oddhead}{%
\vbox{\hbox to \textwidth{\rmfamily\footnotesize%
\rlap{\theartpage}\hfill\hbox{\rrp@headTitle}\hfill\thepage}%
%   \rlap{\color{black} \year@copy}\hfill\hbox{\rrp@headTitle}\hfill\thepage}%
\rule[-1mm]{\textwidth}{0.4pt}%
}}%

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


The artpage does not advance.

## 2 Answers

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!
\renewcommand{\@oddhead}{%
\stepcounter{artpage}%
\vbox{\hbox to \textwidth{\rmfamily\footnotesize%
\rlap{\theartpage}\hfill\hbox{\rrp@headTitle}\hfill\thepage}%
%   \rlap{\color{black} \year@copy}\hfill\hbox{\rrp@headTitle}\hfill\thepage}%
\rule[-1mm]{\textwidth}{0.4pt}%
}}%
%   <--- do not put an empty line into this macro
\renewcommand{\@evenhead}{%
\stepcounter{artpage}%
\vbox{\hbox to \textwidth{\rmfamily\footnotesize%
\thepage\hfill%
\hbox{\rrp@headAuthors}%
\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.

• 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}