我的问题来自于我很难理解 fancyhd 或 titleps 的 readmes 中关于标记的英文解释,因此无法修改标题。我不明白这些标记以及 extramarks 选项引入的标记背后的业务。
从我的 readme 中得知,该titleps
软件包有一个带星号的标记版本,当第一个小节与小节标题位于同一页时,可以正确地考虑它。这解决了 LaTeX 的 bug(我也没有完全理解)。
我没有偏爱哪个包,但 titleps 让我更接近我想要的。在 MWE 之前,我的愿望是
\documentclass[twoside, a4paper, 11pt]{article}
在每一页上:
左上角 =
\thesection--sectiontitle
顶部中间 =
\thepage
右上角 =
\thesubsection--subsectiontitle
但是当我们更改该部分时会出现问题,请参见下文。底部中间 =
\the page
对于目录和参考书目,我只希望在左上角有“目录”,在右上角有页面。
使用直接从自述文件中复制的 MWE,
\documentclass[twoside, a4paper, 11pt]{article}
\usepackage[topmarks, extramarks]{titleps}
\settitlemarks*{section,subsection}
\newpagestyle{funny}{
\setfoot{\toptitlemarks Top is \thesubsection}
{\firsttitlemarks First is \thesubsection}
{\bottitlemarks Bot is \thesubsection}
\sethead{\firstextramarks{section}\thesection---\sectiontitle}
{\firstextramarks{subsection}\thesubsection---\subsectiontitle}
{\thepage}
}
\pagestyle{funny}
\usepackage{lipsum}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\tableofcontents
\newpage
\section{first section}
\lipsum[1-3]
\subsection{first subsetion of the first section}
\lipsum[1-3]
\subsection{second subsetion of the first section}
\lipsum[1-3]
\subsection{third subsetion of the first section}
\lipsum[1-11]
\section{second section}
\lipsum[1-11]
\subsection{first subsetion of the second section}
\lipsum[1-3]
\subsection{second subsetion of the second section}
\lipsum[1-11]
\subsection{third subsetion of the second section}
\lipsum[1-11]
\section{thirs section}
%\lipsum[1-3]
\subsection{first subsetion of the third section}
\lipsum[1-3]
\subsection{second subsetion of the third section}
\lipsum[1-3]
\subsection{third subsetion of the third section}
\lipsum[1-11]
\end{document}
但是,目录的标题存在问题,在第 6 页上,我们可以看到标题对于章节来说是足够的,但对于子章节来说却不够,因为它显示的是第一章节的第三子章节!应该是,
top left= section two
top middle= the page
top right=blank
答案1
我之前的评论只起到了一点帮助。这主要是因为你定义的页面样式,但也因为\subsectionmark{}
会自动“步进”计数器。
我会这么做:
当页面包含部分而没有子部分时,添加额外的页面样式;即,
\newpagestyle{nosubsec}{% \setfoot {\toptitlemarks Top is \thesubsection}% {}% {\bottitlemarks Bot is \thesubsection}% \sethead {\firstextramarks{section}\thesection---\sectiontitle}% {}% {\thepage}% }
修补
\section
和\subsection
命令以自动使用它们。也就是说,make\section
emit the\pagestyle{nosubsec}
然后 make\subsection
emit\pagestyle{funny}
:\usepackage{etoolbox} \pretocmd{\section}{\pagestyle{nosubsec}}{}{} \pretocmd{\subsection}{\pagestyle{funny}}{}{}
您的示例文档将如下所示:
\documentclass[twoside, a4paper, 11pt]{article}
\usepackage{etoolbox}
\usepackage[topmarks, extramarks]{titleps}
\settitlemarks*{section,subsection}
\newpagestyle{funny}{%
\setfoot
{\toptitlemarks Top is \thesubsection}%
{\firsttitlemarks First is \thesubsection}%
{\bottitlemarks Bot is \thesubsection}%
\sethead
{\firstextramarks{section}\thesection---\sectiontitle}%
{\firstextramarks{subsection}\thesubsection---\subsectiontitle}%
{\thepage}%
}
\pagestyle{funny}
\newpagestyle{nosubsec}{%
\setfoot
{\toptitlemarks Top is \thesubsection}%
{}%
{\bottitlemarks Bot is \thesubsection}%
\sethead
{\firstextramarks{section}\thesection---\sectiontitle}%
{}%
{\thepage}%
}
\pretocmd{\section}{\pagestyle{nosubsec}}{}{}
\pretocmd{\subsection}{\pagestyle{funny}}{}{}
\usepackage{lipsum}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\tableofcontents
\newpage
\section{first section}
\lipsum[1-3]
\subsection{first subsetion of the first section}
\lipsum[1-3]
\subsection{second subsetion of the first section}
\lipsum[1-3]
\subsection{third subsetion of the first section}
\lipsum[1-11]
\section{second section}
\lipsum[1-11]
\subsection{first subsetion of the second section}
\lipsum[1-3]
\subsection{second subsetion of the second section}
\lipsum[1-11]
\subsection{third subsetion of the second section}
\lipsum[1-11]
\section{thirs section}
%\lipsum[1-3]
\subsection{first subsetion of the third section}
\lipsum[1-3]
\subsection{second subsetion of the third section}
\lipsum[1-3]
\subsection{third subsetion of the third section}
\lipsum[1-11]
\end{document}
不过,正如我之前所说,整个“标记”系统是一项棘手的工作,并且可以相对容易地欺骗 LaTeX 做一些你不想要的事情......