GeneralCreating customized headers/footers for alternating pages

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
User avatar
tripwire45
Posts: 129
Joined: Thu Apr 10, 2008 4:35 am

Creating customized headers/footers for alternating pages

Post by tripwire45 »

Before you say it, yes, I am using \usepackage{fancyhdr}, but the exact solution escapes me. I have consulted the following threads on this forum:

http://www.latex-community.org/viewtopi ... ader#p3274

http://www.latex-community.org/viewtopi ... ader#p3040

I also downloaded and read the fancyhdf documentation from CTAN.org.

I'm creating a manual that will be put together in book form, so the product name should appear in the header in tiny text, on the left side in even pages and on the right side in odd pages.

The footer should contain the number, copyright info and the words "User Guide" on every page, but the page number should be on the left on even pages and on the right on odd pages, switching places with "User Guide".

I can put the appropriate information in the header and footer now, but need to know how to make that information change, depending on odd and even pages.

Thanks for help with yet another puzzle.

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

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

Creating customized headers/footers for alternating pages

Post by gmedina »

Try using [LE,R0] (as in Left Even, Right Odd) and [LO,RE]. The package documentation explains how to do this and contains examples.

Code: Select all

\documentclass{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{} 
\fancyhead[RO,LE]{\tiny\bfseries The product}
\fancyfoot{} 
\fancyfoot[LE,RO]{\thepage}
\fancyfoot[LO,RE]{User Guide}
\fancyfoot[C]{Other information}
\usepackage{lipsum}

\begin{document}

\lipsum[1-40]

\end{document}
Edit: I added a little example.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Creating customized headers/footers for alternating pages

Post by localghost »

Here is an example of the page layout derived from my settings with fancyhdr before switching to KOMA Script.

Code: Select all

% Page style settings (fancyhdr)
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[LE,RO]{\thepage}
\fancyfoot[LO,RE]{User's Guide \copyright\ Copyright Information}
\fancyhead[RE]{\sffamily\nouppercase{\rightmark}}
\fancyhead[LO]{\sffamily\nouppercase{\leftmark}}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0.5pt}
%\addtolength{\headheight}{2pt}
%\addtolength{\footheight}{2pt}
It should be easy for you to adapt that to your needs. gmedina has already given the hints how to do that.


Best regards
Thorsten¹
User avatar
tripwire45
Posts: 129
Joined: Thu Apr 10, 2008 4:35 am

Creating customized headers/footers for alternating pages

Post by tripwire45 »

I think I like gmedina's solution better (no offense, Thorsten). However, a blank page (with header and footer still present) appears between the copyright page and the Table of Contents page, and I can't see why. Here's how it's set up:

Code: Select all

\begin{document}

%Make title page without date and insert logo on top of the title
\begin{titlepage}
\begin{center}

% Upper part of the page
\includegraphics[width=0.8\textwidth]{img/logo_large.png}\\[1cm]
\textcolor{red}{\textsc{\Huge \textbf{User Guide}}}\\[1cm]
\end{center}
\end{titlepage}
\pagenumbering{roman}

%Create a copyright page as a separate page

 \vspace*{\fill}
\begingroup
\centering
\textbf{Copyright \copyright 2008}\\
by Copyright Stuff.\\
All Rights Reserved\\
\endgroup
\vspace*{\fill}
\newpage

% Insert the table of contents
\tableofcontents
% Set indent of paragraphs to zero
\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}

\newpage
\pagenumbering{arabic}

%Chapter 1
Otherwise, it looks great. :)
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Creating customized headers/footers for alternating pages

Post by gmedina »

tripwire45 wrote:I think I like gmedina's solution better (no offense, Thorsten)...
I do not see how this is possible. We both gave you suggestions; you only had to adapt them to your particular needs.

Anyway, try using the openany class option; i.e., use something like

Code: Select all

\documentclass[openany]{book}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
tripwire45
Posts: 129
Joined: Thu Apr 10, 2008 4:35 am

Creating customized headers/footers for alternating pages

Post by tripwire45 »

gmedina wrote:
tripwire45 wrote:I think I like gmedina's solution better (no offense, Thorsten)...
I do not see how this is possible. We both gave you suggestions; you only had to adapt them to your particular needs.[\quote]

What I mean to say is that your suggestion is more suited to my needs.
gmedina wrote:Anyway, try using the openany class option; i.e., use something like

Code: Select all

\documentclass[openany]{book}
Thanks. It works.
Post Reply