如何在 fancyhdr 标题中显示小节名称以及子小节编号和名称?

如何在 fancyhdr 标题中显示小节名称以及子小节编号和名称?

例如:

\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}

更新的示例展示了我所遇到的问题:

\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}

答案1

尽管使用 无法轻松地完成此操作fancyhdr,但使用 可以相当直接地完成此操作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}

更精美的页眉和页脚

相关内容