使用 \newpagestyle
定义页面样式时,于 \clearpage
后的新 \section
如果自奇数页开始,则第一页无法正确反映 \thesubsection
以及 \subsectiontitle
。
如图,第四页的 header 可以正常加载,而第十一页的 header 不正确:
%!TEX program = pdflatex
\documentclass[a4paper, twoside]{article}
\usepackage[explicit]{titlesec}
\usepackage[extramarks]{titleps}
\usepackage{titletoc}
\usepackage{lipsum}
\title{header testing}
\author{test}
\date{\today}
% formats header and footer
\newpagestyle{main}{
\sethead[\thepage]%
[]%
[\thesubsection \quad \sectiontitle\ -\ \subsectiontitle]%
{\thesubsection \quad \sectiontitle\ -\ \subsectiontitle}%
{}%
{\thepage}%
\setheadrule{0.3pt}
\setfoot[][][]{}{}{}
}
\begin{document}
\maketitle
\pagestyle{plain}
\tableofcontents
\clearpage
\section{Preface}
\lipsum[1-6]
\clearpage
\pagestyle{main}
\section{First section}
\subsection{First subsection}
\lipsum[1-20]
\subsection{Second subsection}
\lipsum[1-20]
\clearpage
\section{Second section}
\subsection{Third subsection}
\lipsum[1-10]
\end{document}
参考 titleps 第九页,(或许可用的)解决方法是:
\settitlemarks*{section,subsection}
% formats header and footer
\newpagestyle{main}{
\sethead[\thepage]%
[]%
[\firstextramarks{subsection}\thesubsection \quad \sectiontitle\ -\ \firstextramarks{subsection}\subsectiontitle]%
{\firstextramarks{subsection}\thesubsection \quad \sectiontitle\ -\ \firstextramarks{subsection}\subsectiontitle}%
{}%
{\thepage}%
\setheadrule{0.3pt}
\setfoot[][][]{}{}{}
}
关于 first / top / bottom mark 的讨论请移步 https://ask.latexstudio.net/ask/question/17859.html .
是的,应该是左右页的问题。同蹲。
@u105324
感觉这个post的标题有些问题
应该只与
titleps
宏包有关(?),而不是titlesec
与titletoc
,要想复现问题,似乎并不需要后两者。maybe realted: https://tex.stackexchange.com/questions/404964/titleps-even-odd-custom-headers-with-subsection-information#comment1009444_404964
但是如果加上
outermarks
,第4页的页眉有问题,第11页恢复正常:所以,接着蹲....
开始以为是 titlesec 重定义了一些 titling 的 macro,测试了一下发现确实是 titleps 自己的问题。(fancyhdr 似乎没有这个问题。)
@u105324 所以为何不用更好的fancyhdr而要退而求其次用这个titleps呢?
@u45041 历史遗留问题,而且 titleps titletoc titlesec 放在一起看上去很酷。
@u45041
似乎...不一定有优劣之分(?),也有可能是在一个已经大范围使用了
titlesec
和titletoc
的文档里,更希望同时使用titleps
...