使用自定义部分样式自动化“部分(续)”

使用自定义部分样式自动化“部分(续)”

这是对https://tex.stackexchange.com/a/63847/243868

当一个部分跨越多页时,我想在页面顶部添加“部分名称(续)”。我尝试使用上述答案中建议的代码,但它不会在分页符处打印任何文本。

这是 MWE。我应该进行哪些更改才能在必要的分页符处重新显示章节标题?

%%%%%%%%%%%%%%%%%basic document setup%%%%%%%%%%%%%%%%%
\documentclass[american, 10pt]{article}
\usepackage{calc}
\reversemarginpar
\usepackage[paper=letterpaper, marginparwidth=1.3in, marginparsep=.05in, margin=1in, includemp]{geometry}
\usepackage{hyperref}
%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%custom section formatting%%%%%%%%%%%%%%%%
% Usage: \section{section name}
\renewcommand{\section}[1]{\pagebreak[3]%
    \vspace{2\baselineskip}%
    \phantomsection\addcontentsline{toc}{section}{#1}%
    \noindent\llap{\scshape\smash{\parbox[t]{\marginparwidth+6pt}{\hyphenpenalty=10000\raggedright #1}}}%
    \vspace{-\baselineskip}\par}

\renewcommand{\subsection}[2][0]{%
    \begin{bf}
        \vspace{#1\baselineskip} #2 \vspace{4pt}\par
\end{bf}}%

%%%%%%%%%%%%%%%%copied from original post%%%%%%%%%%%%%%%%
\usepackage{everyshi}% http://ctan.org/pkg/everyshi
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox

\makeatletter
\let\@section@title@\relax% Sectional heading storage
\patchcmd{\@sect}% <cmd>
{\@xsect}% <search>
{\gdef\@section@title@{% Store sectional heading
        {\noindent#6\@svsec#8\normalfont\ \smash{(continued)}}\par\bigskip}\@xsect}% <replace>
{}{}% <success><failure>
\EveryShipout{%
    \ifdim\pagetotal>\pagegoal% There is content overflow on this page
    \aftergroup\@section@title@% Reprint/-insert sectional heading
    \fi%
}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{lipsum}

\begin{document}
\section{Section 1} 
\lipsum[1-10]
\section{Section 2}
\lipsum[1-5]
\end{document}

相关内容