I am trying to control headers depending on the pagenumber when the article starts. There are several articles so I want to keep their start page in the memory as a constant. I have tried following commands but I am new in latex so I couldn't find any other way to do it.
I have written them in an environment
first option :
\def\pgno{\thepage}
\chead{\pgno} % always gives the current page number not the first page's number
second option :
\newcounter{pgno}
\setcounter{pgno}{\thepage}
\chead{\value{pgno}} % always gives the current page number not the first page's number
I want to use the first page's number in every page in the same environment. How can I do this?
General ⇒ Keeping \thepage variable as a constant
NEW: TikZ book now 40% off at Amazon.com for a short time.

Keeping \thepage variable as a constant
It might help to know exactly how you plan to use this variable.
If you just need to produce the starting page number later on, you can always label the first section, and then use \pageref to refer back to it.
If you just need to produce the starting page number later on, you can always label the first section, and then use \pageref to refer back to it.
Code: Select all
\documentclass{article}
\usepackage{lipsum} % autogenerates text
\title{My Article}
\author{Roy G. Biv}
\begin{document}
\maketitle
\section{First section}\label{firstsection}
\lipsum[1-10] % 10 autogenerated paragraphs
\section{Second section}\label{secondsection}
\lipsum[11-20] % 10 more
\section{Conclusion}\label{thirdsection}
This article began on page~\pageref{firstsection}, and section 2 began on page~\pageref{secondsection}.
\end{document}
Keeping \thepage variable as a constant
Thanks for the reply frabjous. It works. Can I also use its value for some arithmetic operations such as to learn the difference between the current page number and the first page?
Actually what I want to do is to change the header in every page. However when I do it with \ifodd it might fail because not all articles have even number of pages. So not every article starts with an odd page. I want to use article title in the first page of the article all the time and changing it with author's name in even pages. I couldn't manage using \pageref in arithmetic operations, eventhough it gives the page number as expected.
Actually what I want to do is to change the header in every page. However when I do it with \ifodd it might fail because not all articles have even number of pages. So not every article starts with an odd page. I want to use article title in the first page of the article all the time and changing it with author's name in even pages. I couldn't manage using \pageref in arithmetic operations, eventhough it gives the page number as expected.