1

I am having some problems with using the package fancyhdr. My goal is to have small-caps headers (instead of the default upper-case) with the book class and I would like, if possible, to write a code which works regardless if I use the option twoside or oneside.

There is attached a simplified preamble; firstpage is a single-page pdf used as front. The chapters are tex files cap1, cap2, etc, while mybib is for the bibliography.

If I simply use the command \pagestyle{fancy}, a weird thing happens: the headers disappear and a decorative line appears. I tried several other commands but nothing worked.

\documentclass[12pt, openright, twoside]{book}
\usepackage{geometry}
\geometry{letterpaper}

\usepackage{pdfpages}
\usepackage{booktabs}

\usepackage[T1]{fontenc}
\usepackage[english]{babel}


%Abstract
\usepackage{fancyhdr}
\newcommand{\fncyblank}{\fancyhf{}}
\newenvironment{abstract}%
{\cleardoublepage\fncyblank\null \vfill\begin{center}%
\bfseries \LARGE \abstractname \end{center}}%
{\vfill\null}


\begin{document}

\frontmatter
\pagenumbering{Roman}
\includepdf{firstpage}


\selectlanguage{english}%
\begin{abstract}
Test.
\end{abstract}

\tableofcontents
\mainmatter

\include{caps/cap1}
\include{caps/cap2}

\bibliography{mybib}
\bibliographystyle{plain}

\end{document}
1

Maybe the following example will help, but I am not sure if it is the desired result.

\documentclass[12pt,
%  oneside
]{book}
\usepackage{geometry}
\geometry{letterpaper,
  headheight=15.5pt% <- as suggested by fancyhdr
}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{blindtext}% only for dummy text

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[C]{\scshape\nouppercase{\leftmark}}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0pt}% <- remove headrule

%Abstract
\newenvironment{abstract}%
{\cleardoublepage\pagestyle{empty}% <- changed to "empty"
  \null\vfill
  \begin{center}\bfseries \LARGE \abstractname \end{center}%
}%
{\vfill\null\clearpage}

\begin{document}
\frontmatter
\pagenumbering{Roman}
First page
\begin{abstract}
Test.
\end{abstract}
\tableofcontents
\mainmatter
\Blinddocument
\end{document}

Or with the additional information from comments below:

\documentclass[12pt]{book}
\usepackage{geometry}
\geometry{letterpaper,
  headheight=15.5pt% <- as suggested by fancyhdr
}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{blindtext}% only for dummy text

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[LE]{\scshape\nouppercase{\leftmark}}
\fancyhead[RO]{\scshape\nouppercase{\rightmark}}
\renewcommand{\headrulewidth}{0pt}% <- remove headrule

%Abstract
\newenvironment{abstract}%
{\cleardoublepage\pagestyle{plain}% <- changed to "plain"
  \null\vfill
  \begin{center}\bfseries \LARGE \abstractname \end{center}%
}%
{\vfill\null\clearpage}

\begin{document}
\frontmatter
\pagenumbering{Roman}
First page
\begin{abstract}
Test.
\end{abstract}
\tableofcontents
\mainmatter
\Blinddocument
\end{document}
  • Ok, the end result is not the desired one but at least it's a start. The decorative headrule is no-problem. The headings should be in the left/right position exactly as in a twoside, openright book. Default footnotes should be left as they are. – PseudoRandom Oct 10 '17 at 9:45
  • Do not worry about the case of a oneside book. For now, I'm interested only in getting it right for a twoside, openright book. – PseudoRandom Oct 10 '17 at 9:51
  • Another thing: the page with abstract needs to have the page number in it (roman, since it is frontmatter). In your example, it does not, but I believe that the origin of the weird phenomenon is from exactly the fancyhf command used there. – PseudoRandom Oct 10 '17 at 10:01
  • See my updated answer – esdd Oct 10 '17 at 10:11
  • Perfect, thank you! I noticed that headheight=15.5pt looks better (less wasted space) than the default option. Seems weird, I thought LaTeX defaults were pretty good, typographically speaking. – PseudoRandom Oct 10 '17 at 10:13

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.