3

I want to show the sheet number instead page number in the header of odd pages, but it always shows 1:

\documentclass[twoside]{article}

\usepackage{calc}
\usepackage{titleps}

\newcounter{sheet}
\renewcommand*{\thesheet}{\arabic{sheet}}
\setcounter{sheet}{(\thepage+1)/2}

\newpagestyle{mypagestyle}{
    \sethead
    [][][] % even
    {}{Sheet \thesheet}{} % odd
}
\pagestyle{mypagestyle}

\begin{document}

    First page
    \clearpage
    Second page
    \clearpage
    Third page

\end{document}

How can I fix this?

PS: It is important not to modify the \thepage counter to avoid conflicts with other packages.

3

That's because the sheet counter is never incremented with the page counter. Moreover, \thepage could be defined as something other than \arabic{page} and therefore not be a number (use \value{page} in calculations). Regardless, just set the sheet calculation directly in the header via \numexpr:

\newpagestyle{mypagestyle}{
  \sethead
  [][][] % even
  {}{Sheet \number\numexpr(\value{page}+1)/2\relax}{} % odd
}
  • Thanks a lot!!! – Albert Sep 15 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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