0

I am having some issues with setting my thesis formatting and I may need some assistance with the fancyhdr package. The problem is, I made by own style from a combination of two templates and there must be some inherited settings from each of them (and each different), but I am unable to locate them. This is what the pages look like: An example of my problem

As you see, the LEFT pages have the page number as a footer under a line and the RIGHT pages have the page number as a header and with no line. I want to have the chapter name in the headers and page numbers in the footers. This is a part of my preamble:

\documentclass[a4paper,12pt,twoside,openright, english]{book}

% INSTAL THE PACKAGES I WILL MOST LIKELY NEED
\usepackage{siunitx}
\usepackage{cleveref}
\usepackage{latexsym, syntonly, textcomp, amsmath, caption, float}
\usepackage{graphicx}%[pdftex]
\usepackage{subcaption}
%\usepackage{subfig}
\usepackage{wrapfig}
\usepackage{epstopdf}%[outdir=./Figures/]{epspdfconversion}
\usepackage{blindtext, setspace, rotating}
\usepackage{natbib, longtable}
\usepackage[toc,page]{appendix}
\usepackage{babel}
\usepackage{bm}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{threeparttable} %for footnote in tables
\usepackage[hyphens]{url} %break line within long url
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{sidecap}
\usepackage[top=2.3cm, inner=3.2cm, bottom=2.4cm, outer=2.3cm]{geometry}
\usepackage[bookmarks]{hyperref}

\usepackage[strings]{underscore}

% LOWER CASE CHAPTER AND SECTION HEADINGS
\renewcommand{\chaptermark}[1]{%
        \markboth{#1}{}}
\renewcommand{\sectionmark}[1]{%
        \markright{\thesection\ #1}}
\fancyhf{}  % delete current header and footer
\fancyhead[LO,RE]{\bfseries\thepage}
%\fancyhead[LO]{\bfseries\rightmark}
%\fancyhead[RE]{\bfseries\leftmark}
\fancyhead[LE]{\emph\textit{\nouppercase{\rightmark}}}
\fancyhead[RO]{\emph\textit{\nouppercase{\leftmark}}}
\fancyhead[RE]{}
\fancyhead[LO]{}
\fancyfoot[LE]{\thepage}
\fancyfoot[RO]{\thepage}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0.5pt}
\addtolength{\headheight}{3pt} % space for the rule
\fancypagestyle{plain}{%
\fancyhead{} % get rid of headers on plain pages
\renewcommand{\headrulewidth}{0.5pt} % and the line
        }

\onehalfspacing

\tableofcontents
\clearpage
\listoffigures
\addcontentsline{toc}{chapter}{\listfigurename}
\listoftables
\addcontentsline{toc}{chapter}{\listtablename}
\clearpage

What have I missed? I thought I have all the settings.

  • 1
    Please post a MWE (minimal working example) instead of just 'part of your preamble'. Did you select your headerstyle with \thispagestyle{fancy} by any chance, since only the opening pages have it applied? – Henk Metselaar Dec 8 '17 at 7:16
  • Nope, the only things that I excluded were settings of unrelated things (dedication etc., which had its own \thispagestyle{empty}). Otherwise the document begins, that's all – durbachit Dec 8 '17 at 7:58
2

There is at least a \pagestyle{fancy} missing. The normal pages still use pagestyle headings. Note that \pagestyle{fancy} must be used at least once before the redefinition of \chaptermark and \sectionmark, because the first call of \pagestyle{fancy} also redefines this commands.

I am not sure about the desired page layout. Maybe

enter image description here

Code (without all the unrelated stuff):

\documentclass[a4paper,12pt,twoside,openright,english]{book}
\usepackage{babel}
\usepackage{blindtext}% only for dummy text

\addtolength{\headheight}{3pt}
\usepackage{fancyhdr}
\pagestyle{fancy}% <- must be used before the redefinition of \chaptermark and \sectionmark
% change the marks set by \chapter and \section
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
% change fancy style
\fancyhf{}
\fancyhead[LE]{\nouppercase{\rightmark}}
\fancyhead[RO]{\nouppercase{\leftmark}}
\fancyfoot[LE,RO]{\thepage}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0.5pt}
% change plain style (eg. used on chapter pages)
\fancypagestyle{plain}{%
  \fancyhf{}
  \fancyfoot[LE,RO]{\thepage}
  \renewcommand{\headrulewidth}{0pt} % comment this line, if there should be a headsepline on plain pages too
}

\usepackage{blindtext}
\usepackage[nottoc]{tocbibind}% LoF and LoT should get a ToC entry
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\blinddocument
\end{document}

If there should be a headsepline on plain pages too, remove the change of \headrulewidth inside the definition of page style fancyplain.

Additional remark: In your code the \addcontentsline{toc}{chapter}{\listfigurename} and \addcontentsline{toc}{chapter}{\listtablename} are at the wrong place. They would add the page numbers of the last pages of LoF and LoT to the table of contents. You could use package tocbibind instead.

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.