使用 \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 .
由于无法采纳自己的回答,特作此说明。