0

Let me start of by saying I'm pretty new to LaTeX. I'm writing my master's thesis and the following problem has popped up:

I'm writing in XeLaTeX. As I'm setting my chapters to get the general outline of the thesis I sometimes have to use the *-sign after \chapter, not necessarily because I don't want them in the ToC (as a matter of fact, they need to be in it), but I don't want the 'chapter 1'-text on the page itself nor should they be numbered. I'm also using the \fancyhdr-package and this is where it starts to get a bit more complicated.

This is part of the code:

\documentclass[11pt,twoside]{report}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{fontspec} %needed to write in Arial

\usepackage[british]{babel} %language

\usepackage{graphicx} % Required for inserting images
\graphicspath{{images/}}

\usepackage{hyperref}

\usepackage{titlesec}
\assignpagestyle{\chapter}{fancy}
\linespread{1.3} % equal to 1.5 line-width (mandatory)

\usepackage{caption}
\usepackage{subcaption}


\usepackage[a4paper,%width=150mm,
top=30mm,bottom=40mm, left=21.2mm, right=21.2mm, heightrounded]{geometry}

%header and footer
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[RO,LE]{\leftmark}
\fancyhead[LO,RE]{\rightmark}
\fancyfoot{}
\fancyfoot[RO,LE]{\thepage}
\fancyfoot[C]{Thesis Title}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

%due to little errors the following correction:
\setlength{\headheight}{13.59999pt} %for compensation, see next line
\addtolength{\topmargin}{-1.59999pt}


\begin{document}
\setmainfont{Arial}

%\input{chapters/titlepage} < \input-files are empty at this moment in time. I was just getting the outline of the file. There is an ocasional \lipsum (see Introduction); I've now just placed it in the code.

\chapter*{Preface}
\addcontentsline{toc}{chapter}{Preface}
%\input{chapters/preface}

\chapter*{Societal outreach}
\addcontentsline{toc}{chapter}{Societal outreach}
%\input{chapters/societal outreach}

\tableofcontents
\addcontentsline{toc}{chapter}{Contents}


\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
%\input{chapters/abstract}

\chapter{Introduction}
%\input{chapters/introduction}
\lipsum[2]


\end{document}

Now what does that do? it makes a header called 'CONTENTS' of the page of the ToC and the page that starts the abstract. Something that I don't want. It would be fine if both headers are empty (i.e. the way the header of Societal outreach is).

Does anyone know a workaround? Thanks in advance!

3
  • Unfortunately your example does not compile. Neither is \assignpagestyle defined nor do we have the external file, that you \input. So it is not a minimal working example and I can only guess, that moving \assignpagestyle{\chapter}{fancy} behind the \tableofcontents` could help. But note also, that your \addcontentsline for the ToC could be to late (at least if the ToC has more than one page). Using a package like tocbibind could be the better idea. Note also, that \chapter* does not change the marks itself.
    – cabohah
    Jun 9, 2023 at 16:47
  • @cabohah Alright so, first of all, thanks for your reply! I've reworked the MWE, ran it on a new file, and it should compile now (first question I've ever posted here, so I still have a lot to learn). Probably important to note (I didn't in the original question) I'm writing in XeLaTeX. The \input are mostly empty as I've now added in the MWE after a %. I've tried out putting the \assignpagestyle(...){fancy} after abstract and that fixed some problems, but not all. Maybe I could redefine plain-pagestyle like I did with fancy and assign it on everything up to abstract?
    – StanS
    Jun 10, 2023 at 8:10
  • @cabohah Yes so, I did try to redefine the plain-pagestyle and it worked! I assigned it to everything up until introduction and then pasted the assignpagestyle(...){fancy} after \chapter{Introduction} The code I added in the preamble: ``` \fancypagestyle{plain}{ \pagestyle{fancy} \fancyhead{} \fancyfoot{} \fancyfoot[RO,LE]{\thepage} \fancyfoot[C]{Thesis Title} } \assignpagestyle{\chapter}{plain} ``` Thanks for your help! P.S. I will look into tocbibind as well.
    – StanS
    Jun 10, 2023 at 8:21

1 Answer 1

0

After a chat with you guys, I found a solution for my problem: I defined the plain-pagestyle to my liking and then applied them to everything up until the introduction. the extra code in the preamble is:

\fancypagestyle{plain}{
    \pagestyle{fancy}
    \fancyhead{}
    \fancyfoot{}
    \fancyfoot[RO,LE]{\thepage}
    \fancyfoot[C]{Thesis Title}
}
\assignpagestyle{\chapter}{plain}

You must log in to answer this question.

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