LaTeX forum ⇒ Page LayoutCompilation glitches with the fancyhdr package Topic is solved

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

Compilation glitches with the fancyhdr package

Postby Cham » Sat Dec 02, 2017 4:48 pm

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) :

  1. \RequirePackage[l2tabu,orthodox]{nag}
  2. \documentclass[11pt,twoside,aps,pra,nofootinbib,raggedfooter,eqsecnum,tightenlines,notitlepage]{revtex4-1}
  3. \usepackage[T1]{fontenc}
  4. \usepackage{lmodern}
  5. \usepackage{microtype}
  6. \usepackage{showframe}
  7. \usepackage[page]{totalcount}
  8. \usepackage{fancyhdr}
  9. \fancyhf{}
  10. \pagestyle{fancy}
  11. \fancyhead[LE,RO]{Done with \LaTeX}
  12. \fancyhead[CE,CO]{\textsf{\textbf{Some bold text on top}}}
  13. \fancyhead[RE,LO]{\textsl{Text in corner}}
  14. \fancyfoot[CE,CO]{\textsc{SmallCaps text at bottom}}
  15. \fancyfoot[LE,RO]{page \thepage~of \totalpages}
  16. \fancyfoot[RE,LO]{Useless text}
  17. \setlength{\headheight}{12pt}
  18. \renewcommand{\headrulewidth}{0.4pt}
  19. \renewcommand{\footrulewidth}{0.4pt}
  20.  
  21. \begin{document}
  22.  
  23. \title{Title}
  24. \author{Isaac Newton}
  25. \email[Adresse courrielle : ]{isaac.newton@somewhere.com}
  26. \affiliation{Some place for the lazies.}
  27. \begin{abstract}Some resume.\end{abstract}
  28. \maketitle
  29. \tableofcontents
  30.  
  31. \section{Introduction} Some introduction for the goofies.
  32.  
  33. \section{Ssection title} Some section text.
  34.  
  35. \newpage
  36. \section{A dumb title} Some dumb text.
  37.  
  38. \subsection{Subsection title} Subsection text.
  39.  
  40. \newpage
  41. \section{Another title} More text to waste your time.
  42.  
  43. \subsubsection{A stupid subsubsubsubtitle} More useless text for your pleasure.
  44.  
  45. \newpage
  46. Hey ! \LaTeX is fun!
  47.  
  48. \section*{Thanks to myself} Who am I, and who are you ?
  49.  
  50. \begin{thebibliography}{999}
  51. \bibitem{bibitem1}
  52. \uppercase{Galilei,~G., J.~Kepler}, \par \textit{Title 1}, \par Found.\ Phys.\ \textbf{47}, no. 6, 797 (1642).
  53. \medskip
  54. \bibitem{bibitem2}
  55. \uppercase{Einstein,~A., I.~Newton}, \par \textit{Title 2}, \par Phys.\ Rev.\ D \textbf{65}, 103522 (2058).
  56. \end{thebibliography}
  57.  
  58. \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?

User avatar
Stefan Kottwitz
Site Admin
Posts: 8525
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Sat Dec 02, 2017 5:18 pm

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
Site admin

User avatar
Cham
Posts: 813
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Sat Dec 02, 2017 5:44 pm

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: 8525
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Sat Dec 02, 2017 6:37 pm

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
Site admin

User avatar
Johannes_B
Site Moderator
Posts: 3584
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sat Dec 02, 2017 6:43 pm

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: 813
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Sun Dec 03, 2017 12:56 am

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: 3584
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sun Dec 03, 2017 9:33 am

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.


Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 5 guests