I'm using the fancyhdr package in an article with the following code
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE]{\textit{\nouppercase{\leftmark}}}
\fancyhead[LO]{\textit{\nouppercase{\rightmark}}}
At the moment \leftmark and \rightmark give the section and subsection titles. My subsections are pretty short and on a two-page spread there's a big chance the subsection title is actually on the page, so I don't need it in the header to refer to it. But I do have several part*s to my document.
I would like to use the part name (on the even pages) and the section name (on the odd pages) like so:
| 15 Third part* title | §2 2nd section title 16 |
| | |
| Content of the 15th page, | Content of the 16th page, |
| continuing to the next | continuing to the next |
| line. | line. |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
I'm pasting a MWE for testing purposes
\documentclass[twoside]{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength{\headheight}{16pt}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE]{\textit{\nouppercase{\leftmark}}}
\fancyhead[LO]{\textit{\nouppercase{\rightmark}}}
\begin{document}
\part*{First part title}
\section{First section title}
Abc
\newpage
\subsection{First subsection title}
Def
\newpage
\subsection{Second subsection title}
Ghi
\newpage
\part*{Second part title}
\section{Second section title}
Jkl
\newpage
Mno
\end{document}

\pagestyle{empty}for the title and contents pages (like\pagestyle{empty} \maketitle \newpage \tableofcontents \clearpage \pagestyle{fancy}). In combination with your code, I'm getting "oh dear! could not patch [starred] part command..." and the corresponding header remains empty. What can I do to fix this? – Earthliŋ Dec 28 '14 at 23:14hyperrefwill be changing those commands, too. (Andhyperreflikes being loaded late, in most cases.) Glad you figured it out! – cfr Dec 28 '14 at 23:46