这是分页后重新显示章节标题(使用 titlesec):我不想在任何溢出的页面上重复长部分标题,而是想使用简称([]
通过部分命令给出)。
在我们这样做的同时,我也需要在级别上执行此操作\subsection
,因此我破解了 [egreg] 的答案,但实际上我并不知道我在做什么。请参阅我的 MWE,其中包含以下更改以适应子部分级别(如果建议改进以将其应用于子部分级别,我会很高兴):
\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{everyshi}% http://ctan.org/pkg/everyshi
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
\titleformat{name=\subsection}
{\normalfont\bfseries\large}
{\thesubsection}
{1em}
{\gdef\@section@title@{\thesubsection\quad#1 (cont'd)}#1}
\titleformat{name=\subsection,numberless}
{\normalfont\bfseries\large}
{}
{0pt}
{\gdef\@section@title@{#1 (cont'd)}#1}
\titlespacing{\subsection}
{0pt}
{2ex plus 1ex minus .5ex}
{1ex plus .5ex minus .5ex}
\let\@section@title@\relax% Sectional heading storage
\def\print@section@title@{%
{\noindent\normalfont\bfseries\large\@section@title@}\par\vspace{1ex plus .5ex minus .5ex}%
}
\EveryShipout{%
\ifdim\pagetotal>\pagegoal% There is content overflow on this page
\aftergroup\print@section@title@% Reprint/-insert sectional heading
\fi%
}
\makeatother
\begin{document}
\section{A section}\lipsum[1-5]
\subsection[A shorter one]{A very long, long subsection heading}\lipsum[4-9]
\end{document}
所缺少的只是在第 3 页顶部显示“1.1 较短的(续)”:
答案1
这是一个解决方案。使用\@currentlabelname{}
\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{everyshi}% http://ctan.org/pkg/everyshi
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
\titleformat{name=\subsection}
{\normalfont\bfseries\large}
{\thesubsection}
{1em}
{\gdef\@section@title@{\thesubsection\quad\@currentlabelname{} (cont'd)}#1}
\titleformat{name=\subsection,numberless}
{\normalfont\bfseries\large}
{}
{0pt}
{\gdef\@section@title@{\@currentlabelname{} (cont'd)}#1}
\titlespacing{\subsection}
{0pt}
{2ex plus 1ex minus .5ex}
{1ex plus .5ex minus .5ex}
\let\@section@title@\relax% Sectional heading storage
\def\print@section@title@{%
{\noindent\normalfont\bfseries\large\@section@title@}\par\vspace{1ex plus .5ex minus .5ex}%
}
\EveryShipout{%
\ifdim\pagetotal>\pagegoal% There is content overflow on this page
\aftergroup\print@section@title@% Reprint/-insert sectional heading
\fi%
}
\makeatother
\begin{document}
\section{A section}\lipsum[1-5]
\subsection[A shorter one]{A very long, long subsection heading}\lipsum[4-9]
\end{document}