Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am writing my thesis and I would like to have the page numbers on the top right corner of each page. And I would like to not have any page numbers on the first page of each chapter. But, I would like to have page numbers on the first page of the special chapters (e.g., acknowledgements, ToC, LoT, LoF etc)...

I am using the following code (mixed and matched from several postings) that gives me indeed page numbers on the top right corner, except from the first page of each chapter (so far so good). But also except from the first page of the special chapters...

Could I somehow define an environment for some of my chapters to have page numbers on their first page (so for ackn, ToC, etc) and then a different environment for the rest of the chapters?

\RequirePackage{fancyhdr} 
\fancypagestyle{phdthesis}{%
\fancyhf{} 
\fancyhead[R]{\thepage} 
}
\makeatletter
\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
                \thispagestyle{empty}%
                \global
                \@topnum\z@
                \@afterindentfalse
                \secdef\@chapter\@schapter}
\makeatother
share|improve this question

1 Answer 1

Define a new boolean switch (say, \ifspecialchapter), add a test for this switch to your redefinition of \chapter and set the pagestyle of the chapter's first page accordingly. In the document body, use \specialchaptertrue and \specialchapterfalse as desired.

\documentclass{book}

\usepackage{fancyhdr} 
\fancypagestyle{phdthesis}{%
\fancyhf{} 
\fancyhead[R]{\thepage} 
}
\pagestyle{phdthesis}

\newif\ifspecialchapter
\specialchapterfalse

\makeatletter
\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
                \ifspecialchapter
                  \thispagestyle{phdthesis}%
                \else
                  \thispagestyle{empty}%
                \fi
                \global
                \@topnum\z@
                \@afterindentfalse
                \secdef\@chapter\@schapter}
\makeatother

\usepackage{lipsum}

\begin{document}

\specialchaptertrue

\tableofcontents

\specialchapterfalse

\chapter{foo}

\lipsum[1-12]

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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