5

I'm using a standard Latex book shell to typeset a book. Does anyone know how to format page numbering as follows:

  1. for preliminary pages, e.g. title page, contents, preface, etc., put page number at the bottom-center;
  2. for mainmatter, put page number at the top-right.

I tried the follows

\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{\thepage}
\lfoot{}
\cfoot{}
\rfoot{}
\renewcommand{\headrulewidth}{0pt} 
\fancypagestyle{plain}{\pagestyle{fancy}} 

However, they also move the page numbers of preliminary pages to top right which are not desired.

1
  • Welcome to TeX.SX! You can highlight code blocks by indenting with 4 spaces or by clicking the {} icon above the edit window. Good luck!
    – Count Zero
    Aug 6, 2012 at 1:22

1 Answer 1

3

You can define two page styles; one for the preliminary pages and the other one for the mainmatter. Inside your document you can select the desired style using \pagestyle. A little example in which I named the two styles preliminary and mainmatter:

\documentclass{article}
\usepackage{fancyhdr}
\usepackage{lipsum}

\fancypagestyle{preliminary}{
\fancyhf{}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0pt} 
\fancypagestyle{plain}{\pagestyle{preliminary}}
}
\fancypagestyle{mainmatter}{
\fancyhf{}
\fancyhead[R]{\thepage}
\renewcommand{\headrulewidth}{0pt} 
\fancypagestyle{plain}{\pagestyle{mainmatter}}
}


\begin{document}

\pagestyle{preliminary}
\lipsum[1-12]

\clearpage
\pagestyle{mainmatter}
\lipsum[1-12]

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .