The usual way of getting section names in fancyhdr
headers is by doing:
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
However, this doesn't get subsections, subsubsections, paragraphs, nor subparagraphs. I'd like the header to show the name of the last section created up to the current page, no matter if it's a section or a subparagraph.
This of course seems to match \currenttitle
from the titleref
package.
But unfortunately this doesn't work for getting \currenttitle in the header:
\renewcommand{\currenttitle}[1]{\markright{\thesection.\ #1}}
(yes, I know \thesection
is wrong, but I'm first trying to get the current title name, fixing the number will come later).
Are there any workarounds for getting the current title (and its number) in a header by fancyhdr
?
Example which I'd like to modify so that the header displays the last section/subsection/subsubsection/paragraph/subparagraph in the page:
\documentclass[11pt,a4paper]{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhf{}
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\headheight}{14pt}
\fancypagestyle{plain}{
\fancyhead{}
\renewcommand{\headrulewidth}{0pt}
}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\usepackage{blindtext}
\begin{document}
\blinddocument
\end{document}
titleref
doesn't use the titles ofsubsection
etc.fancyhdr
behavior. I wish to change it so that it honors all hierarchical levels of sections.