TeX - LaTeX Asked by Muhammad Ashfaq on April 30, 2021
I am using MastersDoctoralThesis for writing my thesis. Its default settings are:
My university requirements are:
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.
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}
BlinddocumentBlinddocument
BlinddocumentBlinddocument
appendix
BlinddocumentBlinddocument
end{document}
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}
BlinddocumentBlinddocument
BlinddocumentBlinddocument
appendix
BlinddocumentBlinddocument
end{document}
Correct answer by esdd on April 30, 2021
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
defps@myheadings{% create myheadings pagestyle
def@oddfoot{hfilthepagehfil}%
def@evenfoot{hfilthepagehfil}%
def@evenhead{slshaperightmarkhfil@title}%
def@oddhead{slshape Universe City Universityhfilleftmark}%
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}
Answered by John Kormylo on April 30, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP