# How do I show the subsection name and the subsubsection number and name in a fancyhdr header?

For example:

\documentclass{article}
\usepackage{fancyhdr}
\usepackage{blindtext}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\leftmark} % displays the section (1. SECTION NAME)
\fancyhead[R]{\rightmark} % displays the subsection (1.1 SUBSECTION NAME)
\fancyfoot[R]{\thesubsubsection \subsubsectionname}  % doesn't work
% would like the above line to produce (1.1.1 Subsubsection name), for example.

\begin{document}
\blinddocument
\end{document}


Updated example that exhibits the problems I'm having:

\documentclass{article}

\usepackage{tabu,kantlipsum}
\usepackage{longtable}
\usepackage{titleps}
\usepackage{datetime}
\usepackage[left=1cm, right=1cm, bottom=1in]{geometry}
\usepackage[bookmarks]{hyperref}
\usepackage[auth-sc,affil-it]{authblk}

\title{A Title}

\author[1]{An Author\thanks{\texttt{email@email}}}
\affil{Department of LateX}

\date{Dated: \today}

\newpagestyle{mypage}{%
\setfoot{Generated: \today \hspace{1ex} \currenttime}{\thepage}{Some other footer text}
\footrule
}
%\settitlemarks{section, subsection, subsubsection} % cannot do this!!
\settitlemarks{section,subsection,subsubsection} % must NOT put spaces in this!
\pagestyle{mypage}

\begin{document}
\maketitle
\tableofcontents
\pagebreak
\section{Section one}
\kant[1-4]
\subsection{Subsection one}
\kant[5-10]
\subsubsection{Subsubsection one}
\kant[11-20]

\end{document}

• Please give us a complete, small document which demonstrates the issue. As it stands, the obvious answer is, 'Of course it doesn't work. You haven't even \begin{document} yet, let alone included any subsubsections!' which is likely rather unhelpful. – cfr Apr 3 '15 at 22:13
• There is no really straightforward way to do what I think you are trying to do with fancyhdr. However, I may not have understood. – cfr Apr 3 '15 at 22:23
• @cfr updated example – Brian D Apr 6 '15 at 19:37

Although you can't do this easily with fancyhdr, you can do it fairly straightforwardly with titleps.

\documentclass{article}
\usepackage{titleps,kantlipsum}
\newpagestyle{mypage}{%
}
\settitlemarks{section,subsection,subsubsection}
\pagestyle{mypage}

\begin{document}
\section{Section one}
\kant[1-4]
\subsection{Subsection one}
\kant[5-10]
\subsubsection{Subsubsection one}
\kant[11-20]

\end{document}


• Trying to stick with fancyhdr, though this does look like a useful alternative. – Brian D Apr 6 '15 at 19:38
• @BrianD I default to fancyhdr myself. I used something else here because it is much more straightforward and probably much more reliable than anything I could cook up myself. See Werner's comment - manipulating LaTeX's marks is one of the Dark Arts. – cfr Apr 6 '15 at 20:21
• @BrianD The subsubsection information just is not saved in the same way as the section and subsection information. You can get the section number - although it might not always be the one you'd expect - but getting the title requires something further. titleps has special facilities for creating, saving and utilising marks and is far and away superior to fancyhdr for a job with your desiderata. – cfr Apr 6 '15 at 20:24
• a fair point. I tried both answers and they work fine with a trivial example, but start to break down in my full document. I end up with the subsub/sub/section numbers but no titles with your solution... not sure why. I also get subsubsections listed that don't exist (i.e., 1.1.0 in the header when that subsubsection does not exist in my document) – Brian D Apr 6 '15 at 20:33
• found the error in my code that was causing the subsection and subsubsection titles not to generate... ugh. – Brian D Apr 6 '15 at 22:14

You can combine Herbert's clever answer to how to get the current chapter name, section name, subsection name, etc? with fancyhdr as follows.

\documentclass{article}
\usepackage{fancyhdr}
\usepackage{blindtext}

\pagestyle{fancy}
\let\Sectionmark\sectionmark
\def\sectionmark#1{\def\Sectionname{#1}\Sectionmark{#1}}
\let\Subsectionmark\subsectionmark
\def\subsectionmark#1{\def\Subsectionname{#1}\Subsectionmark{#1}}
\let\Subsubsectionmark\subsubsectionmark
\def\subsubsectionmark#1{\def\Subsubsectionname{#1}\Subsubsectionmark{#1}}

\fancyhf{}
\fancyhead[L]{\thesection.\ \Sectionname} % displays the section (1. SECTION NAME)
\fancyhead[R]{\thesubsection.\ \Subsectionname} % displays the subsection (1.1 SUBSECTION NAME)
\fancyfoot[R]{\thesubsubsection.\ \Subsubsectionname}

\begin{document}
\blinddocument
\end{document}


• article doesn't have chapters. – cfr Apr 3 '15 at 22:38
• This will only capture the last section on a page, and might even not be the correct one... – Werner Apr 3 '15 at 22:39
• @cfr Fixed. That' what I get for blindly copy/pasting. – erik Apr 3 '15 at 22:53
• @erik, worked in trivial example, but in full document I got errors about "Undefined Control Sequence" related to the newly defined commands: "Sectionname", "Subsectionname", and "Subsubsectionname" – Brian D Apr 6 '15 at 20:44
• Initially this looked promising, but apparently it's not sufficiently robust. Sorry it didn't work for you. – erik Apr 6 '15 at 21:01