Document ClassesPage numbering layout in fancyhdr

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
idaham
Posts: 21
Joined: Wed May 21, 2008 4:30 pm

Page numbering layout in fancyhdr

Post by idaham »

Hi!
I'm trying to do a simple thing, but can't get it to work! I want to change the footer layout in the "fancyhdr" package so that even pages have the pagenumber to the left, and odd pages the number on the right. I've found lots of examples, but when I apply them it just doesn't work! I've done like this:

Code: Select all

\usepackage{fancyhdr}
\fancyfoot{}
\renewcommand{\footrulewidth}{0.4pt}
\fancyfoot[LE,RO]{\thepage}
You'd think this should work, but it doesn't. The strange thing is that all pages are aligned according to what I assign to the ODD pages (even if I change the order I write odd/even in the code), i.e. if I write \fancyfoot[LE,RO]{\thepage} all numbers (both odd and even pages) are to the right, and if I write \fancyfoot[LE,LO]{\thepage} all numbers are to the left. It doesn't matter what I assign to even pages. What am I doing wrong?? Thanks a lot to anyone who knows!
/Ida

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Page numbering layout in fancyhdr

Post by gmedina »

Hi,

maybe you forgot to declare fancy as the page style to be used. Take a look at the following example:

Code: Select all

\documentclass{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot{}
\renewcommand{\footrulewidth}{0.4pt}
\fancyfoot[LE,RO]{\thepage}
\usepackage{lipsum}%just to generate some text

\begin{document}

\lipsum[1-40]

\end{document}
If the problem persists after adding \pagestyle{fancy}, then please post a minimal working example illustrating your problem.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
idaham
Posts: 21
Joined: Wed May 21, 2008 4:30 pm

Page numbering layout in fancyhdr

Post by idaham »

Hello, and thanks for helping me!
I have declared the pagestyle to fancy, so I'm still very confused as to what the problem is. I've summed up a little file code that I run, where I tried to change the pagenumbering. It doesn't work for me, same problem as I mentioned above... For the code below I get the page number on the right on both even and odd pages.

Code: Select all

\documentclass[a4paper,11pt]{article}
\usepackage[cp1252]{input enc} %om kompilerningen sker på en Windows-maskin
\usepackage[margin=20pt,font=small,labelfont={bf,it},textfont=it,labelsep=period]{caption}
\usepackage[nooneline,footnotesize,bf,it,IT]{subfigure}
\usepackage{fancyhdr}
\RequirePackage[calcwidth]{titlesec}
\RequirePackage{color}
\usepackage{fix-cm}
\usepackage[swedish,english]{babel}
%%Define a fancy section layout
\definecolor{blue}{rgb}{0,0,1}
\titleformat{\section}[hang]{\sffamily\bfseries}{
\fontsize{100}{100}\selectfont\color{blue}\thesection}{0pt}{\linebreak\huge\raggedleft}[{\titlerule[0.5pt]}]

\pagestyle{fancy}

\fancyfoot{}
\renewcommand{\footrulewidth}{0.4pt}
\fancyfoot[RO,LE]{\thepage}
%------------------------------------
\begin{document}

\selectlanguage{english}
\setcounter{page}{1}
\renewcommand{\thepage}{\arabic{page}}

\section{Section}
hello
\pagebreak
\section{Section}
hello
%------------------------------------
\end{document}
I really hope I've just made a simple mistake that can easily be fixed! =)
Cheers,
Ida
blueflow
Posts: 1
Joined: Thu Oct 30, 2008 4:35 am

Re: Page numbering layout in fancyhdr

Post by blueflow »

you need to specify that your document is two-sided. Use \documentclass[twoside]{article} and the pagestyles will work
idaham
Posts: 21
Joined: Wed May 21, 2008 4:30 pm

Page numbering layout in fancyhdr

Post by idaham »

Thank you, this is exactly what I need! =)
blueflow wrote:you need to specify that your document is two-sided. Use \documentclass[twoside]{article} and the pagestyles will work
Post Reply