General ⇒ Keeping \thepage variable as a constant
Keeping \thepage variable as a constant
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?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Keeping \thepage variable as a constant
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
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.