I am currently using a header on my document that should do one of a few things.
If the current page is before any chapters or sections are defined, the header should only contain a number.
If there are any sections or chapters defined before the current page, the name of the last defined section / chapter should be in the header.
There are two excpetions to this rule. If there is a new chapter, there should be no header on the page or table of contents.
If there is a title page, there should be no footer / header.
This works great. However, when a table of contents is added, all the headers become prefixed with CONTENTS. How can I prevent the headers being prefixed with CONTENTS without affecting any of the header functionality that was described above.
There is also a case when there is no section or title in the header, but there is a table of contents, the header is consists of CONTENTSCONTENTS.
If it makes a difference, I am building using LuaTex on the latest version of TexLive (downloaded today)
\documentclass[a4paper,oneside]{book}
\usepackage{lipsum}
\usepackage{fancyhdr}
%Header / Footer info
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markright{#1}}
\renewcommand{\sectionmark}[1]{\markright{#1}}
%Define the header / footer
\fancyhf{}
\fancyhead[L]{\topmark}
\fancyhead[R]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\begin{document}
\begin{titlepage}
hello
\end{titlepage}
\tableofcontents
\clearpage
\lipsum[1-10]
\clearpage
\section{Paragraphs 1 - 10}
\lipsum[1-10]
\clearpage
\chapter{Lorem Ipsum :)}
\lipsum[1-5]
\section{Paragraphs 6 - 10}
\lipsum[6-10]
\section{Paragraphs 11 - 15}
\lipsum[11-15]
\end{document}
\topmarkdoesn't work correctly in LaTeX. Afaik, the only way to get correct heads with top marks is with (my)titleps(see sec. 5 of its manual). – Javier Bezos Sep 02 '18 at 16:12titleps(I really like how I can use it by the way. I prefer the formatting to fancyhdr's) but I still had the issue of contents being included. At the time I was using similar code to the code found in this answer – Dan Sep 02 '18 at 16:36