0

apologies if this is a simple fix or obvious!

I am relatively new to latex, learning it as I go and using the internet and places like this almost exclusively.

I am writing my thesis and would like to have the generic "fancy header" pagestyle for each chapter. However, it only applies this rule to the second chapter and none of the others.

All the chapters are separate files which include nothing but "\chapter{title}" and possibly sections and subsections.

I have no idea how or why this is happening, or even if I am required to include something inside each separate chapter.tex file. I have no warnings or errors displayed either.

I understand that the header is only applied from page two onwards however, even with 2 pages worth of introduction the header only appears from page three onwards.

Thanks in advance for any help / assistance!

    \documentclass[11pt]{report}
    \usepackage[utf8]{inputenc}
    \usepackage[a4paper, margin=25mm]{geometry}
    \usepackage[english]{babel}
    \usepackage{times}

    % Hyperlinks toc/lof/lot
    \usepackage[hyperindex=true]{hyperref}
    \hypersetup
    {
      colorlinks   = true,    % Colours links instead of ugly boxes
      urlcolor     = blue,    % Colour for external hyperlinks
      linkcolor    = blue,    % Colour of internal links
      citecolor    = red      % Colour of citations
    }

    % adds image package and formatting
    \usepackage{graphicx}
    \usepackage{subcaption}
    \usepackage{float}
    \graphicspath{{./Images/}}

    % adds general maths symbols
    \usepackage{textcomp,gensymb}

    % formats section headings
    \usepackage{titlesec}
    \titleformat{\chapter}
    {\large\bfseries}{\thechapter.}{11pt}{\large}
    \titleformat{\section}
    {\bfseries}{\thesection}{11pt}{\normalsize}
    \titleformat{\subsection}
    {\itshape\bfseries}{\thesubsection}{11pt}{\normalsize}

    % adds fancy headers
    \usepackage{fancyhdr}
    \setlength{\headheight}{14pt}
    \pagestyle{fancy}

    % Define Bibliography
    \usepackage[super,numbers,sort&compress]{natbib}
    \bibliographystyle{naturemag}

    % formatting for toc
    \usepackage{tocloft}
    \addto\captionsenglish{\renewcommand*\contentsname{Table of Contents}}
    \renewcommand\cftloftitlefont{\large\textbf}
    \renewcommand\cftlottitlefont{\large\textbf}
    \renewcommand\cfttoctitlefont{\large\textbf}

    %-------------------------------------------------------------------------

    % Start Dissertation

    %-------------------------------------------------------------------------

    \title
    {
    {Title}\\
    \author{\textbf{...}\\
    \textbf{University}\\
    \textbf{Submission Date: }
    \date{\today}\\ 
    \textbf{Student:} Student ID\\
    \textbf{Supervisor:} Supervisor}
    }

    \begin{document}

    \maketitle

    %-------------------------------------------------------------------------

    % Opening Pages

    %-------------------------------------------------------------------------

    \pagenumbering{roman}
    \input{Chapters/abstract.tex}
    \newpage

    % add toc
    \begin{centering}
    \tableofcontents
    \end{centering}
    % adds "page" above numbers
    \addtocontents{toc}{~\hfill\textbf{Page}\par}

    \newpage
    % add "acknowledgements" to toc
    \phantomsection
    \addcontentsline{toc}{chapter}{Acknowledgements}
    \input{Chapters/acknowledgements.tex}
    \newpage

    % adds lof to toc
    \phantomsection
    \addcontentsline{toc}{chapter}{\listfigurename}
    \begin{centering}
    \listoffigures
    \end{centering}
    \newpage

% adds lot to toc
\phantomsection
\addcontentsline{toc}{chapter}{\listtablename}
\begin{centering}
\listoftables
\end{centering}
\newpage

\pagenumbering{arabic}

%-------------------------------------------------------------------------

% Main body of paper

%-------------------------------------------------------------------------

\input{Chapters/introduction.tex}
\input{Chapters/coupling_methods.tex}
\input{Chapters/loss_measurement_techniques.tex}
\input{Chapters/results.tex}
\input{Chapters/discussion.tex}
\input{Chapters/conclusion.tex}

\bibliography{WG_characterisation}

\appendix
\chapter{Appendix}
\input{Chapters/appendix.tex}

\end{document}

%-------------------------------------------------------------------------
5
  • 1
    I'm not sure of the answer off-hand, but you might get more lookers if you trimmed this down to a more manageable size (see tex.meta.stackexchange.com/q/228/107497). For example, most of those packages shouldn't affect the headings, and you can use the lipsum package to get a few pages of text to show what happens when you get to the second or third page. (And if you stumble upon a truly interesting "package notheader breaks fancyhdr", then you'll get everyone's attention.)
    – Teepeemm
    Jan 29, 2020 at 2:33
  • We can't directly run your document to test it of course because you use a lot of \inputs. I removed all the superfluous stuff to reproduce your error, but the headers look fine. Maybe you have some lines inside the input documents that mess with the headers? Could you elaborate on "it only applies this rule to the second chapter and none of the others"? For example add a screenshot.
    – TivV
    Jan 29, 2020 at 9:35
  • This is the first few pages; dropbox.com/sh/o336l5z3abqzcmu/AADisk07rh0Hw3ki9PKjO7Uga?dl=0 . Each file begins \chapter{} ...blurb... \section{} ...blurb... and so on. I have tried taking the \chapter{} line out of the files and placing it before \insert{} in the main.tex, which does seem to make a difference. I get the feeling the interpreter isnt recognising each file as a new chapter, more of a new "first" chapter. If i make the introduction longer then the header appears but for the next chapter it skips the first page. Do I have to have seperate files for each section etc?
    – SeanK
    Jan 29, 2020 at 13:54
  • I haven't tried to test this, but it's typical practice for the first page of a chapter to have only the page number at the bottom, and no header at the top. Try this: just after a \chapter line, add \thispagestyle(fancy}. Jan 29, 2020 at 17:03
  • I see now, the screenshot really helped me understand! The code has no errors as such, it's just that the pagestyle per default gets redefined at the first page of a chapter in such a way that it removes the headers as well.
    – TivV
    Jan 29, 2020 at 19:23

1 Answer 1

1

It is behaving exactly as intended, but since you changed the way chaptertitles are displayed to basically look like sectiontitles it might seem a bit odd to you. At the page where a new chapter starts the pagestyle plain is applied automatically (like for example in the titlepage), which suppresses the headers. As barbara beeton commented, just put \thispagestyle{fancy} right after the \chapter{...} to redefine this page only.

Reducing your problem to the minimum, this code:

\documentclass[11pt]{report}
\usepackage[a4paper, margin=25mm]{geometry}
\usepackage[english]{babel}

% adds fancy headers
\usepackage{fancyhdr}
\setlength{\headheight}{14pt}
\pagestyle{fancy}

\begin{document}

\chapter{First chapter (without headers)}

\chapter{Second chapter (with headers)}
\thispagestyle{fancy} 

\end{document}

produces this output:

first chapter second chapter

Alternatively, you could also just redefine the plain style (but I'm not sure that is recommended), this answer explains how.

1
  • Thank you very much, I knew it was going to be something simple!
    – SeanK
    Jan 31, 2020 at 14:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .