~~titlesec~~ titleps \newpagestyle 中 subsection 相关内容在奇数页失效

发布于 2025-07-28 09:07:26

使用 \newpagestyle 定义页面样式时,于 \clearpage 后的新 \section 如果自奇数页开始,则第一页无法正确反映 \thesubsection 以及 \subsectiontitle

如图,第四页的 header 可以正常加载,而第十一页的 header 不正确:

image.png
image.png

%!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}

查看更多

关注者
0
被浏览
182
2 个回答
Ethebeth
Ethebeth 1天前
这家伙很懒,什么也没写!

参考 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 .

飘石
飘石 2天前
这家伙很懒,什么也没写!

我试了一下,如果把twoside删掉,就可以了。
\documentclass[a4paper]{article}
原因不知道。继续等大佬吧。

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览