0

I am using the fancyhdr package. I have chapters, sections, subsections, and subsubsections to my book.

I currently show chapters and sections on alternating pages in the running headers.

But in every chapter there are a few subsections out of the dozen or so that I would like instead in the header on those pages.

The example below has two subsections with the one subsection "Subsection in Header" I would like in the header. I understand that for a one-off scenario like in the example below I could define a fancypagestyle. But the issue is that I would need to define 100 of these for the 100 of 300 subsections I would like in the header.


\usepackage[margin=.75in]{geometry}
\usepackage{parskip}

\usepackage{lipsum}

\usepackage{fancyhdr}
\pagestyle{fancy}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[LO]{\rightmark}
\fancyhead[RE]{\leftmark}

\setcounter{tocdepth}{2}


\begin{document}

\tableofcontents

\part{First Part}

\chapter{First Chapter}

\section{First Section}
\lipsum[4-20]

\subsection*{First Subsection}
\lipsum[11-25]

\subsection*{Subsection in Header} % this subsection should be in the header on odd pages (so page 11)
\lipsum[17-40]

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.