4

There's an answer that would theoretically address this issue, but the code doesn't seem to be effective - possibly because it's not meant for use with a book class document.

What I'd like is to display page numbers alternatively in the bottom left and right corners, and the code below uses fancyhdr, but the page numbers are being rendered alternatively in the left margin and the center. Even being in the left and odd in the center (or apparent center).

\documentclass[11pt, twoside]{book}     
\usepackage{geometry}                       
\geometry{letterpaper}                   
\usepackage{pdfpages}       
\usepackage{amssymb}
\usepackage{fancyhdr}
\fancyhf{} % clear all header and footers
\renewcommand{\headrulewidth}{0pt} % remove the header rule

\fancyfoot[LE,RO]{\thepage} % Left side on Even pages; Right side on Odd pages
%
\pagestyle{fancy}
\title{Another Book}
\author{An Author}
\date{}                         
\includepdfset{pagecommand=\thispagestyle{plain}}
\setlength{\footskip}{114pt}
\begin{document}

Is there something that's overriding the \fancyfoot code?

  • 3
    Do you really need \includepdfset{pagecommand=\thispagestyle{plain}}? I guess that it could be the problem. Try to comment it. – Sigur Dec 19 '14 at 22:15
  • 3
    The plain style applies the page number in the center of the foot in the book class. You need to redefine plain as well. – Johannes_B Dec 19 '14 at 22:20
  • Are you including the document using \includepdf, or are you creating a document from scratch? – Werner Dec 19 '14 at 23:00
  • Actually most of the book is PDF files as it's a book of songs, compiled with lilypond. The numbers on those pages are also showing up centered, but that I imagine needs to be addressed separately. – MikeiLL Dec 19 '14 at 23:05
5

The first page of a chapter uses the plain style, as noted in the comments. I've also removed the PDF setting commands as those seem unnecessary, and I've used \geometry to set \footskip. [Otherwise, geometry won't know about the change and won't adjust things appropriately.]

page numbers bottom left and bottom right on two-sided layout

\documentclass[11pt, twoside, letterpaper]{book}
\usepackage{geometry}
\usepackage{kantlipsum}
\usepackage{fancyhdr}
\fancyhf{} % clear all header and footers
\renewcommand{\headrulewidth}{0pt} % remove the header rule
\fancyfoot[LE,RO]{\thepage} % Left side on Even pages; Right side on Odd pages
\pagestyle{fancy}
\fancypagestyle{plain}{%
  \fancyhf{}%
  \renewcommand{\headrulewidth}{0pt}%
  \fancyhf[lef,rof]{\thepage}%
}

\title{Another Book}
\author{An Author}
\date{}

\geometry{footskip=114pt}% don't set this manually else geometry won't know!

\begin{document}
  \maketitle
  \chapter{Some Kant}
  \kant[1-20]
\end{document}

If you wanted to change the style for the title page, as well, you would need to make an appropriate adjustment. However, it is not usual to include a page number on the title page, so I'm assuming you do not desire this.

| improve this answer | |
  • Very nice! Works even on the \includepdf pages. Is there something above I could adjust to move the page numbers further out into the margins? – MikeiLL Dec 19 '14 at 23:12
  • 1
    @MikeiLL \fancyfootoffset[le,ro]{30pt} will move the page numbers 30pt into the margin. You need to add it to the redefinition of plain and to the fancy configuration. Is that what you mean? And, yes, it works fine with pdfpages - I use it that way sometimes myself. (But it wasn't relevant to the MWE.) – cfr Dec 19 '14 at 23:19
  • Exactly what I needed. What's MWE? Does that refer to the original question? I didn't want to confuse the issue by asking more than one question in a single post. – MikeiLL Dec 19 '14 at 23:27
  • 2
    @MikeiLL You've escaped this particular piece of jargon so far? Hah! No longer: minimal working example (MWE). For many questions, an MnWE may be more appropriate (Minimum non-Working Example), although nMWEs are more common (non-Minimal Working Examples) and nMnWnEs are not unheard of (non-Minimal non-Working non-Examples i.e. lots of irrelevant code which won't compile and wouldn't illustrate the problem even if it did). [Note that these descriptors are in no way intended to characterise your questions. I just have a twisted sense of humour.] – cfr Dec 20 '14 at 0:05
  • 2
    I'm sure there's a acronym for smiling ear to ear and nMnWnE definitely got me there. Thanks. – MikeiLL Dec 20 '14 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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