3

I am quite new to TeX. I'm writing my thesis and I want to place the page numbers at bottom left for even pages and bottom right for odd pages. I've done this and it works for even pages, but the odd ones have the page number at the center. Any idea what I'm doing wrong?

\documentclass[11pt, twoside]{book}
\usepackage{geometry, amsmath, float, fancyhdr, standalone}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[LE,RO]{\thepage}
3
  • fancy style is not applied to the first page, I suppose. Does the problem disappears if you put \makeatletter\let\ps@plain\ps@fancy\makeatother in the preamble? Dec 12, 2013 at 14:51
  • Yeah, it works! Thank you! Can you explain how your command works? I don't understand it at all. fancy is not applied to the first page, why are you asking?
    – user_3849
    Dec 12, 2013 at 14:58
  • BTW: Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Dec 12, 2013 at 15:13

1 Answer 1

9

First pages of chapters, table of contents, and other "special" pages are defined to have a plain page style (\thispagestyle{plain} can be found in the definition of \chapter and so in \tableofcontents, etc.).

Even when you apply the fancy page style through the fancyhdr package, these pages continue to have the plain style.

So, if you want these pages to have the fancy style, you have to redefine the plain style to be the same of the fancy one:

\makeatletter
\let\ps@plain\ps@fancy % plain style = fancy style
\makeatother

The same can be achieved with

\fancypagestyle{plain}{}

I also suggest you to add the following line

\renewcommand{\headrulewidth}{0pt} % remove the header rule

to remove the header rule, since you are putting nothing in the header.

Complete example:

\documentclass[11pt, twoside]{book}
\usepackage{geometry, amsmath, float, fancyhdr, standalone}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt} % remove the header rule
\fancyfoot[LE,RO]{\thepage}
\makeatletter
\let\ps@plain\ps@fancy % plain style = fancy style
\makeatother

\usepackage{blindtext} % just for the example

\begin{document}
\blinddocument % just for the example
\end{document} 

Output (first two pages):

enter image description here

EDIT

If you want to keep the header line in all pages but plain ones, forget what I said and simply put the line

\fancypagestyle{plain}{\renewcommand{\headrulewidth}{0pt}}

in the preamble.

In this way you are redefining the plain style to be the same of fancy except for the header rule.

Code:

\documentclass[11pt, twoside]{book}
\usepackage{geometry, amsmath, float, fancyhdr, standalone}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[LE,RO]{\thepage}

\fancypagestyle{plain}{\renewcommand{\headrulewidth}{0pt}}

\usepackage{blindtext} % just for the example

\begin{document}
\blinddocument % just for the example
\end{document} 

Output:

enter image description here

5
  • Thanks for the detailed explanation. I will accept your answer. Just one more question: What if I want to keep the header rule at all pages, except the first page of each chapter?
    – user_3849
    Dec 12, 2013 at 15:18
  • @Ellie See the edited answer. Dec 12, 2013 at 15:28
  • Nice, it works! But still, if I have a header I don't want it to appear on the first page of each chapter, but just where the header rule is. If I change its style to plain, everything is messed uo again. But \fancyhead[LE,RO]{\leftmark} is not enough for this, right?
    – user_3849
    Dec 12, 2013 at 15:47
  • @Ellie In this case use \fancypagestyle{plain}{\renewcommand{\headrulewidth}{0pt}\fancyhead{}} Dec 12, 2013 at 15:56
  • Just found it out! Thank you very much for your help!
    – user_3849
    Dec 12, 2013 at 15:57

You must log in to answer this question.

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