[Tex/LaTex] Page numbering, book class

booksfancyhdrpage-numbering

So in the default book class, the page number for chapters appears at the bottom of the page. I just want the page numbering to alternate left and right, as it does for all other pages.

How can I change the different behavior for pages where there is a chapter?

I have googled the problem and I am aware the package fancyhdr may be of some use, but I don't understand how to use it (yes I read some of the documentation and I still don't understand). So far I just use its default behavior:

\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhead[LE,RO]{\slshape \rightmark}
\fancyhead[LO,RE]{\slshape \leftmark}
\fancyfoot[C]{\thepage}

\begin{document}
\Stuff
\end{document}

EDIT:
I want the page numbers to appear in the header. I've changed the code to look like this:

\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhead[LE]{\slshape \rightmark}
\fancyhead[RO]{\slshape \leftmark}
\fancyhead[LO,RE]{\thepage}

\begin{document}
\Stuff
\end{document}

What this does is to alternate the pages depending on whether it is odd or even, but for chapters, the pages are still centered. Also, I now have page numbers listed in BOTH the header AND the footer for ALL pages…

Best Answer

The letters in square brackets tell you, which position in the header or footer the contents of the curly brackets will be positioned in. L, R, C are left, right, and center, O and E are odd and even. So \fancyfoot[C]{\thepage} will print the current page number cnetered in the footer. It might be useful to have a look at the documentation.

After your edit, I’d recommend you clear all headers and footers in the pagestyle fancy with \fancyhf{} and redefine the pagestyle plain that is used by the \chapter-command with \fancypagestyle:

\documentclass{book}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}%clear all headers and footers
\fancyhead[LE]{\slshape \rightmark}
\fancyhead[RO]{\slshape \leftmark}
\fancyhead[LO,RE]{\thepage}

\fancypagestyle{plain}{%
\fancyhf{}%clear all headers and footers
\renewcommand{\headrulewidth}{0pt}%header rule invisible
}

\usepackage{lipsum}

\begin{document}
\chapter{Stuff}
\lipsum
\section{More stuff}
\lipsum
\chapter{Different stuff}
\lipsum
\section{Different stuff in a section}
\lipsum
\end{document}
Related Question