So I am working on a rather small latex document and can't explaint the behavior of \firstmark
on the table of content
page.
Tell me if I'm wrong, but in my understanding \firstmark
holds the first section heading on the current page. On the \tableofcontents
page this should be CONTENTS
I think.
In the table of content
header this becomes CONTENTSCONTENTS
and on the page itself it becomes just nothing. The CONTENTS
on the left of the heading is irrelevant. I could remove this easily, but I just let it there to get the minimal source.
I got this small .tex source that reproduces this behavior:
\documentclass{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[R]{\firstmark}
\begin{document}
\tableofcontents
foo
\firstmark
bar
\end{document}
And this is the pdf I get from this:
As you can see in the heading on the upper right, there is CONTENTSCONTENTS
instead of just a single CONTENTS
and where you should see CONTENTS
between foo
and bar
, there is absolutely nothing.
I also copied this source to LaTeX Base, to exclude the possibility that this is an error on my computer.
Could someone explain this behavior to me?