\toptitlemarks
并且\bottitlemarks
似乎不适用于随机计数器:
\documentclass[paper=a4,pagesize=pdftex]{scrbook}
\usepackage[pagestyles]{titlesec}
\usepackage{lipsum}
\newcounter{mycounter}
\newpagestyle{mystyle}{
\setheadrule{.009pt}
\sethead[\thepage][]
[\toptitlemarks\themycounter---%
\bottitlemarks\themycounter]%
{\toptitlemarks\themycounter---%
\bottitlemarks\themycounter}{}{\thepage}
}
\pagestyle{mystyle}
\begin{document}
\stepcounter{mycounter}
\markboth{\themycounter}{\themycounter}
\Huge\themycounter
\lipsum[2]
\stepcounter{mycounter}
\markboth{\themycounter}{\themycounter}
\Huge\themycounter
\lipsum[2]
\end{document}
生成:
有没有什么办法可以让它工作?
答案1
该titleps
软件包提供了自己的机制来处理新标记。您可以extramarks
使用titleps
软件包文档(第6. 加分):
\documentclass[paper=a4,pagesize=pdftex,twoside]{scrbook}
\usepackage[extramarks]{titleps}
\usepackage{lipsum}
\newcounter{mycounter}
\newmarkset{mycounter}
\newextramark*{mycounter}{mycounter}
\newpagestyle{mystyle}{
\setheadrule{.009pt}
\sethead[pg(\thepage)][]
[(\topextramarks{mycounter}{\arabic{mycounter}}---%
\botextramarks{mycounter}{\arabic{mycounter}})]%
{(\topextramarks{mycounter}{\arabic{mycounter}}---%
\botextramarks{mycounter}{\arabic{mycounter}})}{}{pg(\thepage)}
}
\pagestyle{mystyle}
\newcommand\updatemark{%
\stepcounter{mycounter}%
\extramark{mycounter}%
}
\begin{document}
\updatemark
\Huge\themycounter
\lipsum[2]
\updatemark
\Huge\themycounter
\lipsum[2]
\end{document}