Page LayoutCompilation glitches with the fancyhdr package

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Compilation glitches with the fancyhdr package

Post by Cham »

I'm experiencing a few small glitches with my customized header/footer, and I have a few questions.

1. What is the best "universal" (i.e. compatible with most classes) up-to-date package to customize the headers and footers in LaTeX ? I'm using fancyhdr in the MWE below.

2. Is the fancyhdr package compatible with all the following classes? (apparently, it's working great with all of them yet, in my experimentations) : article, book, memoir, paper, report, revtex4, scrartcl, scrbook, scrreprt, exam.

Here's a MWE for the revtex4-1 class (a pesky and difficult to customize class), showing the warnings glitches in the console (I'm getting similar warnings with many other classes as well) :

Code: Select all

\RequirePackage[l2tabu,orthodox]{nag}
\documentclass[11pt,twoside,aps,pra,nofootinbib,raggedfooter,eqsecnum,tightenlines,notitlepage]{revtex4-1}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage{showframe}
\usepackage[page]{totalcount}
\usepackage{fancyhdr}
\fancyhf{}
\pagestyle{fancy}
\fancyhead[LE,RO]{Done with \LaTeX}
\fancyhead[CE,CO]{\textsf{\textbf{Some bold text on top}}}
\fancyhead[RE,LO]{\textsl{Text in corner}}
\fancyfoot[CE,CO]{\textsc{SmallCaps text at bottom}}
\fancyfoot[LE,RO]{page \thepage~of \totalpages}
\fancyfoot[RE,LO]{Useless text}
\setlength{\headheight}{12pt}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

\begin{document}

\title{Title}
\author{Isaac Newton}
\email[Adresse courrielle : ]{isaac.newton@somewhere.com}
\affiliation{Some place for the lazies.}
\begin{abstract}Some resume.\end{abstract}
\maketitle
\tableofcontents

\section{Introduction} Some introduction for the goofies.

\section{Ssection title} Some section text.

\newpage
\section{A dumb title} Some dumb text.

\subsection{Subsection title} Subsection text.

\newpage
\section{Another title} More text to waste your time.

\subsubsection{A stupid subsubsubsubtitle} More useless text for your pleasure.

\newpage
Hey !  \LaTeX is fun!

\section*{Thanks to myself} Who am I, and who are you ?

\begin{thebibliography}{999}
\bibitem{bibitem1}
\uppercase{Galilei,~G., J.~Kepler}, \par \textit{Title 1}, \par Found.\ Phys.\  \textbf{47}, no. 6, 797 (1642).
\medskip
\bibitem{bibitem2}
\uppercase{Einstein,~A., I.~Newton}, \par \textit{Title 2}, \par Phys.\ Rev.\ D \textbf{65}, 103522 (2058).
\end{thebibliography}

\end{document}
Here's the typical warnings I'm getting in the console. I don't understand how to properly fix them :
Package Fancyhdr Warning: \fancyhead's `E' option without twoside option is useless on input line 11.
Package Fancyhdr Warning: \fancyhead's `E' option without twoside option is useless on input line 12.
Package Fancyhdr Warning: \fancyhead's `E' option without twoside option is useless on input line 13.
Package Fancyhdr Warning: \fancyfoot's `E' option without twoside option is useless on input line 14.
Package Fancyhdr Warning: \fancyfoot's `E' option without twoside option is useless on input line 15.
Package Fancyhdr Warning: \fancyfoot's `E' option without twoside option is useless on input line 16.
...snip...
Package nag Warning: Command \it is an old LaTeX 2.09 command.
(nag) Use \itshape or \textit instead on input line 32.
...snip...
Package Fancyhdr Warning: \headheight is too small (12.0pt):
Make it at least 13.59999pt.
We now make it that large for the rest of the document.
This may cause the page layout to be inconsistent, however.
...snip...
Package nag Warning: 1 complaints in total.
So what's wrong with my code above? How to make it better? How to fix each warning?

Unrelated questions :
Also, should I use \ (for a space), \\, or \par, or \newline (or even something else) in the bibliography?

Recommended reading 2024:

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

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Compilation glitches with the fancyhdr package

Post by Stefan Kottwitz »

1. Practically universal: that's probably fancyhdr, the classic package for headers and footers. But not up-to-date. It hasn't been developed since many years, also that's why nag prints warnings about obsolete commands. By default capitalized headings are also questionable.

The most up-to-date package is scrlayer-scrpage, the successor of scrpage2. It integrates with the KOMA-Script classes, but I guess it can be used with other classes too.

2. It should be compatible with most. Probably not with memoir, since that one implements package features as copies already.

For unrelated questions, it would be good to have a separate topic. It's hard to follow a mix of questions with mixed answers, especially when several people write then. And you know, people read this topic because of the title, fancyhdr, not for finding a question about bibliography tweaks.

Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Compilation glitches with the fancyhdr package

Post by Cham »

Stefan, what about the other warnings in the MWE above ?

Why the \headheight is too small (12.0pt) ?

And why the E option without twoside option is useless on input line 11 ?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Compilation glitches with the fancyhdr package

Post by Stefan Kottwitz »

Cham wrote:Why the \headheight is too small (12.0pt) ?
You have set it to 12pt, but the contained text in the header is bigger. In your example, compare the header boxes of first and second page. Just set it to 14.
Cham wrote:And why the E option without twoside option is useless on input line 11 ?
The fancyhdr package doesn't see that it's twoside since the revtex4-1 class doesn't make it like the standard book class. If it's just a warning but no issue with the output, ignore it. fancyhdr works like requested, it just comments that in case of oneside layout there's no effect of the E option.

Stefan
LaTeX.org admin
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Compilation glitches with the fancyhdr package

Post by Johannes_B »

As i said in another post, use scrlayer-scrpage. You get warnings by using fancyhdr with KOMA-classes.
You get a nag warning, because your distribution is outdated. fancyhdr is up-to-date by 2017.

revtex is doing something the standard classes do, but in a different way. hence the warnings about the twoside stuff.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Compilation glitches with the fancyhdr package

Post by Cham »

Johannes, I don't understand your comment about outdated distribution. My whole installation (including fancyhdr, KOMA-script and revtex4-1) is all from 2015. Why would nag say anything if fancyhdr is from 2015 too ?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Compilation glitches with the fancyhdr package

Post by Johannes_B »

nag is complaining about the old version of fancyhdr. The package was updated in 2016, latest update in july this year. There is no nag warning with a recent distribution.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply