2

This question may have already been asked but I cannot seem to find the answer or figure this out.

I am using the muthesis template to write my thesis. This gives the chapter title on even pages as "Chapter x. Name of chapter" but then on odd pages gives the section name and number.

How can I make it just give me "Chapter x. Name of chapter" on ALL pages (plus page number as it currently is).

I suspect this can be done with fancyhdr but I do not know how to do this.

Please note I am using a two sided document.

Hope someone can help!

Here is a MWE:

\documentclass[11pt,PhD,twoside]{muthesis}
\usepackage{textcomp}
\usepackage{graphicx}
\usepackage{todonotes}
\usepackage{amsmath}
\usepackage{amstext}
\usepackage{paralist}
\usepackage{enumitem}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage[font=footnotesize,labelfont=bf]{caption}
\usepackage{stackengine}
\usepackage[aboveskip=2pt]{subcaption} % aboveskipchanges spacing     beten caption and figure
\usepackage{caption}
\captionsetup[subfigure]   {justification=justified,singlelinecheck=false} %%% alignment of  subfigure captions

\usepackage{pgfplotstable}
\usepackage[UKenglish]{datetime}
\usepackage{parskip}
\usepackage{booktabs}

\usepackage{colortbl}

\pgfplotstableset{col sep=comma}
\usepackage[none]{hyphenat}
\usepackage{subfig}
\usepackage{multirow}
\usepackage{lscape}
\usepackage{cite}


% for references\
\usepackage{natbib}  
%\setlength{\bibhang}{5em}
%%%%%% Make font smaller
\renewcommand{\bibfont}{\normalfont\small}
%%% to sort out issues with urls
\usepackage[hyperindex,breaklinks]{hyperref}

\usepackage{cite}
\usepackage{graphics}
\usepackage{amstext}
\usepackage{amsmath}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{booktabs}
\usepackage{url} % typeset URLs reasonably
\usepackage{listings}

%%%%%% section size
\usepackage[]{titlesec}

\titleformat{\section}
{\normalfont\fontsize{13}{15}\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\fontsize{13}{15}\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}
{\normalfont\fontsize{13}{15}\bfseries}{\thesubsubsection}{1em}{}
\titleformat{\subsubsubsection}
{\normalfont\fontsize{13}{15}\bfseries}{\thesubsubsubsection}{1em}{}

%%%% Number of sections that are numbered increase
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
%%%%%%%%%%%%%%%
\begin{document}

\title{A thesis}
\author{AN Author}

\school{School of}
\faculty{Faculty}
\def\wordcount{57103}

\beforeabstract
\section*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
\sloppy
\begin{spacing}{1.0}
\fontsize{12}{12}\normalfont
abstract   abstract   abstract   abstract   abstract   abstract        abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   
\end{spacing}

\afterabstract
\prefacesection{Acknowledgements}
I would like to thank......

\afterpreface

\chapter{Introduction}
\section{Background}
Background Background Background Background Background Background     Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background 
\clearpage
\section{Background2}
Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background 
\clearpage
\section{Background3}
Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background 
\end{document}
6
  • Where can i find muthesis?
    – Johannes_B
    Sep 19 '15 at 12:05
  • Here is where I got the template from (I am just a latex beginner)- hope you can find what you would need here? maths.manchester.ac.uk/study/postgraduate/…
    – MarinaWM
    Sep 19 '15 at 12:07
  • I think booktabs is great but your enthusiasm for it seems to border on the obsessional: do you really need to load it quite so often? In general, cleaning up your preamble will help prevent problems and make them easier to diagnose when you do have them.
    – cfr
    Sep 19 '15 at 18:43
  • I get an error trying to compile your code.
    – cfr
    Sep 19 '15 at 18:45
2

A couple of things:

  • The only reason to use this class is that you need to satisfy the institutional requirements it implements. If this is the case, changing the layout will result in your work being deemed inadmissible.

  • If this is not the case, you would be far better advised to use a different class. This one is quite explicit about the fact that it violates rules of good typography. It has to. The institutional requirements demand poor typography.

  • As it stands, your code does not compile without error. This is closely connected to the next point.

  • Your preamble is a mess. This makes it harder to ensure consistency, increases the chances that packages will conflict, makes weird, mysterious problems almost certain, and makes it more difficult to diagnose problems when they inevitably occur.

    • Don't load a package more than once.
    • Especially, don't load a package with different options.
    • Don't load multiple packages which are designed to format the same document elements in different ways e.g. enumitem and paralist; subcaption and subfig.
    • Don't load superfluous packages e.g. url as well as hyperref; graphics as well as graphicx.
    • Pay attention to important ordering requirements e.g. hyperref should be loaded late.
    • Use as many packages as you need and no more than you need.
  • Don't typeset your entire thesis with \sloppy unless your institution explicitly requires such a typographical monstrosity. (This is not likely: I've never heard of them requiring this one, even though they frequently require typographical monstrosities of other kinds.)

In answer to the specific question, \afterpreface sets the page style to headings. Redefining this command to set it to fancy allows fancyhdr settings to take effect:

double spread

Complete code with some more specific annotations follows. I've tried to group packages which provide similar functionality together to make it easier to see what you need and what you don't. If you don't know why you are using a package, comment it out and see if that breaks your compilation. If not, you probably can do without it.

I have, however, added fontenc to get the T1 font encoding which is highly recommended and will get you scalable type1 fonts, as well.

\documentclass[11pt,PhD,twoside]{muthesis}
\usepackage[T1]{fontenc}% recommended
\usepackage{textcomp}
\usepackage{todonotes}
\usepackage{amsmath}
\usepackage{amstext}
% \usepackage{paralist}% enumitem provides similar functionality - stick to one interface
\usepackage{enumitem}
% tables
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{booktabs}
% captions and floats
\usepackage[font=footnotesize,labelfont=bf]{caption}
\usepackage[aboveskip=2pt]{subcaption} % aboveskipchanges spacing     beten caption and figure
\captionsetup[subfigure]   {justification=justified,singlelinecheck=false} %%% alignment of  subfigure captions
% \usepackage{subfig}% if you are using subcaption, don't try to use subfig, too - this way lies madness
\usepackage{stackengine}
% colour, graphics, diagrams
\PassOptionsToPackage{table}{xcolor}
\usepackage{graphicx}% don't load graphics as well - this covers it all already
\usepackage{pgfplotstable}
\pgfplotstableset{col sep=comma}
\usepackage[UKenglish]{datetime}
\usepackage{parskip}
\usepackage[none]{hyphenat}
\usepackage{lscape}

% for references
% \usepackage{cite}% do you really want this as well as natbib? they are likely to fight!
\usepackage{natbib}
%\setlength{\bibhang}{5em}
\renewcommand{\bibfont}{\normalfont\small}

\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{listings}

\usepackage[]{titlesec}
\usepackage{fancyhdr}

% to sort out issues with urls
\usepackage[hyperindex,breaklinks]{hyperref}% load late: loads url - no need to load separately

\titleformat{\section}
{\normalfont\fontsize{13}{15}\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\fontsize{13}{15}\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}
{\normalfont\fontsize{13}{15}\bfseries}{\thesubsubsection}{1em}{}
\titleformat{\subsubsubsection}
{\normalfont\fontsize{13}{15}\bfseries}{\thesubsubsubsection}{1em}{}

\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}

\def\afterpreface{\newpage
        \pagestyle{fancy}}
\pagestyle{fancy}
\fancyhf{}
\renewcommand*\headrulewidth{0pt}
\fancyhf[leh,roh]{\thepage}
\fancyhf[loh,reh]{\slshape\leftmark}

\begin{document}

\title{A thesis}
\author{AN Author}

\school{School of}
\faculty{Faculty}
\def\wordcount{57103}

\beforeabstract
\section*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
% \sloppy% don't do this: It applies \sloppy to the rest of your document which is almost certainly not what you want
\begin{spacing}{1.0}
\fontsize{12}{12}\normalfont% is this a requirement? Because it will give you ugly output which is hard to read
abstract   abstract   abstract   abstract   abstract   abstract        abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract   abstract
\end{spacing}

\afterabstract
\prefacesection{Acknowledgements}
I would like to thank......

\afterpreface

\chapter{Introduction}
\section{Background}
Background Background Background Background Background Background     Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background
\clearpage
\section{Background2}
Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background
\clearpage
\section{Background3}
Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background Background
\end{document}
2
  • I know it's not the done thing here, but thank you @cfr, this worked perfectly. Yes, it was a total mess!
    – MarinaWM
    Sep 19 '15 at 19:50
  • @MarinaWM You're welcome. I hope it helps. It is easy to let preambles get out of hand. I think it not coincidence that 'bramble' and 'preamble' rhyme!
    – cfr
    Sep 19 '15 at 19:54
3

You can define each side by identifying each side with options identifying the even and odd page numbers as well as the side of the header you want to use. This format is from a book I am working on which pushes the headers to the 'outside' of the open pages..

\fancyhead{} % clear all header fields
\fancyhead[RO]{The Book Title}  % [RO] here means Right/Odd numbered page
\fancyhead[LE]{\chaptername \ \thechapter}  % {LE] here means Left/Even numbered page

In your case, include \thepage in order to insert page numbers wherever you want them.

\fancyhead{} % clear all header fields
\fancyhead[RO]{\chaptername \ \thechapter \ \thepage}  % [RO] here means Right/Odd numbered page
\fancyhead[LE]{\chaptername \ \thechapter \ \thepage}  % {LE] here means Left/Even numbered page
3
  • That looked promising but still doesn't seem to work. I still get the section title as the header. Any other ideas?
    – MarinaWM
    Sep 19 '15 at 12:30
  • post a minimal section of your code for us to see. It may be a pre formatted function of muthesis template that you need to reset. Sep 19 '15 at 13:13
  • have posted above by editing my original question- hope it makes sense
    – MarinaWM
    Sep 19 '15 at 13:40

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.