For my thesis I wish to alternate the header for even and odd pages like this template. I looked at the code of that template, but it was a bit too complicated for me to apply it to my own file.
On the even pages I want the page number on the left side and the subsection name on the right side. On the odd pages I want the page number on the right side and the section name on the left side. Lastly, I want pages where a new section starts to not have a header and to be able to specify other pages where I do not wish to have a header.
I tried the following using fancyhdr with the article as documentclass:
\usepackage{fancyhdr}
\fancyhf{}
\fancyhead[LO]{\nouppercase{\rightmark}}
\fancyhead[RE]{\nouppercase{\leftmark}}
\fancyhead[LE,RO]{\thepage}
\pagestyle{fancy}
However, instead of the name of the subsection it returns 'Table of Contents' for the even pages until the page where the references start. For the odd pages it works fine for the section name. How can I change this behavior? Full preamble looks like this:
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
% For tables
\usepackage{array}
\usepackage{booktabs}
% for having numbers aligned to the decimal point
\usepackage{siunitx}
% For captions
\usepackage[labelfont=bf]{caption}
% Include graphics from pdf or jpg file
\usepackage{graphicx}
% For citations
\usepackage{apacite}
\bibliographystyle{apacite}
\graphicspath{{Images/}}
\usepackage{xstring}
\usepackage{titleps}
\usepackage{subcaption} %Side by side table alignment
\usepackage{makecell} %Split table headers into multiple lines
% bold math symbols
\usepackage{bm}
\usepackage{tikz}
\usepackage[titletoc]{appendix}
% easily write third, fourth, fifth etc.
\usepackage[super]{nth}
\usepackage{tikz}
\usepackage{mathdots}
\usepackage{yhmath}
\usepackage{cancel}
\usepackage{color}
\usepackage{multirow}
\usepackage{amssymb}
\usepackage{gensymb}
\usepackage{tabularx}
\usetikzlibrary{fadings}
% Change contents to table of contents
\renewcommand{\contentsname}{Table of Contents}
\renewcommand\labelitemi{$\cdot$}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\raggedbottom
\usepackage{fancyhdr}
\fancyhf{}
\fancyhead[LO]{\nouppercase{\rightmark}}
\fancyhead[RE]{\nouppercase{\leftmark}}
\fancyhead[LE,RO]{\thepage}
\pagestyle{fancy}
titleps
andfancyhdr
, which tackle the same things.