1

I am writing my Bachelorthesis in sharelatex.com and compiling with XeLaTeX. In the following code I want the \tableofcontents \listoffigures and \listoftables to have the pagenumbering in Roman lettering at the top right. However it does not work. The rest of the pages has it. I want it in the style of \fancyhdr. Is there a way to force this? or did I miss anything?

\documentclass[12pt,a4paper,oneside]{article}
\usepackage[top=25mm,bottom=20mm,left=35mm,right=30mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{graphicx} % für Grafiken
%\usepackage[]{hyperref}
\usepackage{amsmath}
\usepackage{titlesec}
\usepackage{amssymb}
\usepackage{caption} %Überschriften für Bilder
\captionsetup{font={small,it}}
\usepackage{listings}
\usepackage{color}
\usepackage{times}
\usepackage[numbers,square]{natbib}
\usepackage{blindtext}
\usepackage{fancyhdr}
\usepackage{tabto}
\usepackage{paracol}
\usepackage{tocloft}
\usepackage[onehalfspacing]{setspace}
\usepackage{nomencl}
\usepackage{tabularx}
\usepackage{float} %Position erzwingen
\usepackage{array} %feste Spaltenbreite einstellbar
\usepackage{eurosym}
\usepackage{subcaption}
\usepackage{acronym}


\begin{document}
\begin{titlepage}
    \centering
    \Huge
    Titlepage
\end{titlepage}

\setlength{\parindent}{0em} %keine Einrückung nach Absatz


\pagestyle{fancy}
\fancyhf{}
\setcounter{page}{1}
\fancyhead[R]{\thepage}
%\renewcommand{\headrulewidth}{0.5pt}
\pagenumbering{Roman}


\addcontentsline{toc}{section}{Affidavit}
\section*{Affidavit}
Affidavit
\clearpage   %\input{Affidavit}

\tableofcontents
\clearpage

\addcontentsline{toc}{section}{List of Abbreviations}
\section*{List of Abbreviations}

\begin{acronym}[TCP]
\acro{TCP}{Transmission Control Protocol}
\end{acronym}

\clearpage


\listoffigures
\addcontentsline{toc}{section}{List of Figures}
\clearpage

\listoftables
\addcontentsline{toc}{section}{List of Tables}
\clearpage



\fancyhead[L]{\nouppercase{\rightmark}}

\pagenumbering{arabic}

\section{Mainbody}
Text

\clearpage


% \pagenumbering{Roman}
% \fancyhf{}
% \rhead{\thepage}
% \setcounter{page}{6}
% \addcontentsline{toc}{section}{References}\clearpage
% \nocite{*}
% \bibliographystyle{unsrtnat}
% \bibliography{References}
% \clearpage

% \begin{appendix}
%  \input{Sections/Appendix}\clearpage
% \end{appendix}

\end{document}
2
  • Commands like \maketitle and \tableofcontents use \thispagestyle{plain}. You can either disable this feature (\let\thispagestyle=\@gobble) or redefine plain (see \fancypagestyle{plain} on pages 7-8). Commented Jul 14, 2018 at 15:43
  • Thank you very much, you made my day @JohnKormylo! I changed it and it worked. The answer is at the bottom and also in the link it is changed.
    – Alan
    Commented Jul 14, 2018 at 18:10

2 Answers 2

2

You could use

\tocloftpagestyle{fancy}

to change the page style of the first page in ToC, LoF and LoT to fancy. (By default tocloft uses plain for these pages even if the class is article.)

Example:

\documentclass{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{\thepage}

\usepackage{tocloft}
\tocloftpagestyle{fancy}%<- sets the page style on the first page of ToC, LoF and LoT

\usepackage[nottoc]{tocbibind}%<- add an ToC entry for LoF and LoT

\usepackage{blindtext}
\begin{document}
\pagenumbering{Roman}
\tableofcontents
\clearpage
\listoffigures
\clearpage
\listoftables
\cleardoublepage
\pagenumbering{arabic}
\Blinddocument
\end{document}

Result:

enter image description here

Note that I have used package tocbibind to get an entry of LoF and LoT in ToC.

Without package tocbibind you could use:

\cftafterloftitle{\addcontentsline{toc}{section}{\listfigurename}}
\cftafterlottitle{\addcontentsline{toc}{section}{\listtablename}}
2
  • yes that works fine as well! And this step can be omitted, which I almost forgot (I am quite new to LaTeX): \addcontentsline{toc}{section}{List of Figures}
    – Alan
    Commented Jul 15, 2018 at 9:04
  • Yes, do not add the ToC entries manuelly. The code in your MWE would result in wrong page numbers in ToC if LoF or LoT needs more than one page (your code uses the page number of the last LoF/LoT page). You could load package tocbibind or use tocloft commands (see my updated answer). BTW If the answer helps, then you can upvote it.
    – esdd
    Commented Jul 15, 2018 at 9:22
0

Thank you to @John Kormylo I changed the "pagestyle settings" to: and it worked immediately!

\fancyhf{}
\pagestyle{fancy}
\fancyhead[R]{\thepage}
\pagenumbering{Roman}
\fancypagestyle{plain}  %%%%%%%VERY IMPORTANT%%%%%%%%%%

You must log in to answer this question.

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