0

I am using MastersDoctoralThesis for writing my thesis. Its default settings are:

  • On even numbered pages: outer header has page number while inner header has chapter number
  • On odd numbered pages: outer header has page number while inner header had section number

My university requirements are:

  • On even numbered pages: outer header should have section number while inner header should have thesis title
  • On odd numbered pages: outer header should have university name while inner header should have chapter number

I am successful in putting university name on page headers. However, I am unable to make the desired layout. I have done some work on lines 277-295 of MastersDoctoralThesis.cls. I have commented some original code.

\RequirePackage[markcase=used]{scrlayer-scrpage}
\providepairofpagestyles{thesisSimple}{%
    \clearpairofpagestyles%
%   \automark[chapter]{chapter}
%   \ihead{\headmark}% Inner header
%   \ohead[\pagemark]{\pagemark}% Outer header
    \automark[chapter]{chapter}
    \ohead{Jiangsu University Master's Degree Thesis}
    \ihead{\headmark}% Inner header
}
\ifoot{}% Inner footer
\ofoot{}% Outer footer
\pagestyle{thesisSimple}
%\pagestyle{scrheadings}
\providepairofpagestyles[thesisSimple]{thesis}{%
    \automark*[section]{}
    \ofoot[\pagemark]{\pagemark}
}

Note: Somehow fancyhdr is not supported by MastersDoctoralThesis.cls (line 302). Maybe we need to tweak scrlayer-scrpage.

3
  • 4
    I won't go to some external site to debug your document and a class from a commercial site. You should provide a small complete example here. – Ulrike Fischer Feb 4 at 11:08
  • @UlrikeFischer I have provided some relevant code. Please let me know if something more is needed – Muhammad Ashfaq Feb 4 at 11:12
  • 1
    Looking over the KOMA docs, they pretty much use standard page styles (with the addition of a few feaures like \chapterpagestyle). – John Kormylo Feb 4 at 14:42
2

It is not recommended to edit the class file. Change the settings in the document preamble:

\pagestyle{thesis}% defined by the class using package scrlayer-scrpage
\clearpairofpagestyles
\lehead{\ttitle}
\rehead{\rightmark}
\lohead{\leftmark}
\rohead{\univname}
\ofoot*{\pagemark}% or should there be no page number at all?

Example:

\documentclass[english,headsepline]{MastersDoctoralThesis}[2017/08/27]% v1.6 LaTeXTemplates.com
\usepackage{fontspec}
\usepackage{blindtext}% only for dummy text

\pagestyle{thesis}% defined by the class using package scrlayer-scrpage
\clearpairofpagestyles
\lehead{\ttitle}
\rehead{\rightmark}
\lohead{\leftmark}
\rohead{\univname}
\ofoot*{\pagemark}% or should there be no page number at all?

\thesistitle{Thesis Title}
\university{\href{http://www.university.com}{University Name}}

\begin{document}
\frontmatter
\pagestyle{plain}
\tableofcontents
\mainmatter
\pagestyle{thesis}
\Blinddocument\Blinddocument
\Blinddocument\Blinddocument
\appendix
\Blinddocument\Blinddocument
\end{document}

enter image description here


Update

If there should be only "Chaptern <chapter number>" and "Section <section number>" in inner header, you can add the following code in the preamble before you select page style thesis:

\providecaptionname{english}{\Sectionname}{Section}
\makeatletter
\AddToLayerPageStyleOptions{thesis}{onselect={%
  \renewcommand*{\chaptermark}[1]{\markboth{\chaptermarkformat}{}}%
  \renewcommand*{\sectionmark}[1]{\markright{\sectionmarkformat}}%
  \renewcommand*\chaptermarkformat{\@chapapp~\thechapter}%
  \renewcommand*\sectionmarkformat{\Sectionname~\thesection}%
}}
\makeatother

Example:

\documentclass[english,headsepline]{MastersDoctoralThesis}[2017/08/27]% v1.6 LaTeXTemplates.com
\usepackage{fontspec}
\usepackage{blindtext}% only for dummy text

\providecaptionname{english}{\Sectionname}{Section}
\makeatletter
\AddToLayerPageStyleOptions{thesis}{onselect={%
  \renewcommand*{\chaptermark}[1]{\markboth{\chaptermarkformat}{}}%
  \renewcommand*{\sectionmark}[1]{\markright{\sectionmarkformat}}%
  \renewcommand*\chaptermarkformat{\@chapapp~\thechapter}%
  \renewcommand*\sectionmarkformat{\Sectionname~\thesection}%
}}
\makeatother

\pagestyle{thesis}
\clearpairofpagestyles
\lehead{\ttitle}
\rehead{\rightmark}
\lohead{\leftmark}
\rohead{\univname}
\ofoot*{\pagemark}

\thesistitle{Thesis Title}
\university{\href{http://www.university.com}{University Name}}

\begin{document}
\frontmatter
\pagestyle{plain}
\tableofcontents
\mainmatter
\pagestyle{thesis}
\Blinddocument\Blinddocument
\Blinddocument\Blinddocument
\appendix
\Blinddocument\Blinddocument
\end{document}

enter image description here

6
  • Yes, there should be page number too, EXACTLY at the position where you specified. :) – Muhammad Ashfaq Feb 5 at 2:15
  • Is there is way, how can we customize \leftmark and \rightmark? For example, what if we only want to show chapter number, omitting 'chapter' word or only "Chapter 1" omitting chapter name? – Muhammad Ashfaq Feb 5 at 2:31
  • Because some of my chapter titles can be really long. For example: FSCS-SIMD: An efficient implementation of Fixed-Size-Candidate-Set adaptive random testing using SIMD instructions – Muhammad Ashfaq Feb 5 at 2:41
  • Should all chapters and sections use only "Chapter 1" and "Section 1" in the page header? – esdd Feb 5 at 17:28
  • All chapters and sections should use relevant chapters sections. I gave "Chapter 1" as an example for the first chapter. – Muhammad Ashfaq Feb 6 at 1:50
1

Here is an example of how to create a page style (myheadings). I used scrbook instead of your thesis, but it should still work.

I added the words Chapter and Section and used \arabic{section} instead of \thesection. It should be noted that \chaptermark is called by \chapter and is passed the chapter title, while \sectionmark is called by \section and is passed the section title (which I ignored). This is so that if more than one section is on a page, the first section is used instead of the last.

\documentclass{scrbook}

\makeatletter
\def\ps@myheadings{% create myheadings pagestyle
    \def\@oddfoot{\hfil\thepage\hfil}%
    \def\@evenfoot{\hfil\thepage\hfil}%
    \def\@evenhead{\slshape\rightmark\hfil\@title}%
    \def\@oddhead{\slshape Universe City University\hfil\leftmark}%
    \let\@mkboth\@gobbletwo% disable
    \renewcommand*{\chaptermark}[1]{\markboth{\@chapapp\ \thechapter. \ }{}}%
    \renewcommand*{\sectionmark}[1]{\markright{Section \arabic{section}. \ }}% no \sectionname defined
    }
\makeatother

\pagestyle{myheadings}
\renewcommand*{\chapterpagestyle}{myheadings}

\title{My Thesis}
\author{Me}

\usepackage{lipsum}% not part of solution

\begin{document}
\frontmatter
\maketitle
\mainmatter
\chapter{First}
\section{Test}
\lipsum[1-12]
\end{document}

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.