6

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}{%
  \headrule
  \sethead{ \thesection\quad \sectiontitle }{ \thesubsection\quad \subsectiontitle }{ \thesubsubsection\quad \subsubsectiontitle }
  \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}
3
  • 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
    Commented Apr 3, 2015 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
    Commented Apr 3, 2015 at 22:23
  • 1
    @cfr updated example
    – Brian D
    Commented Apr 6, 2015 at 19:37

1 Answer 1

7

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

\documentclass{article}
\usepackage{titleps,kantlipsum}
\newpagestyle{mypage}{%
  \headrule
  \sethead{\MakeUppercase{\thesection\quad \sectiontitle}}{}{\thesubsection\quad \subsectiontitle}
  \setfoot{}{}{\thesubsubsection\quad \subsubsectiontitle}
}
\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}

fancier headers and footers

9
  • 1
    Trying to stick with fancyhdr, though this does look like a useful alternative.
    – Brian D
    Commented Apr 6, 2015 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
    Commented Apr 6, 2015 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
    Commented Apr 6, 2015 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
    Commented Apr 6, 2015 at 20:33
  • found the error in my code that was causing the subsection and subsubsection titles not to generate... ugh.
    – Brian D
    Commented Apr 6, 2015 at 22:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .