I want to have the chapter name and title of the document appear in the header; I know how to do that with fancyhdr
and titling
, one of the miscellaneous functions of the latter is to preserve the \thetitle
command which can be used to extract the title of the document later on.
Now I added on the titlesec
package to make the section/chapter headings look better. But here I run into a problem: titlesec
seems to be overwriting \thetitle
with the contents of \thesection
or \thesubsection
!
An example to show the problem:
\documentclass{report}
\usepackage{titling}
\usepackage{titlesec}
\newpagestyle{testfancy}{%
\headrule%
\sethead{\thetitle}{}{\chaptertitle}}
\pagestyle{testfancy}
\title{My title}
\author{This author}
\begin{document}
\maketitle
\chapter{A chapter}
some filler text
\newpage
some more filler text
\newpage
\section{Now a section is added}
\end{document}
On page 3, the left header is displayed (as defined and intended) to be the value of \thetitle
, which in this case is "My title". On page 4, however, after the new section, the left header now shows as "1.1", the value of \thesection
.
Is this conflict documented somewhere? And is there a fix/workaround?