如何生成“-分页符后的“继续”标题与 longtable 配合使用吗?

如何生成“-分页符后的“继续”标题与 longtable 配合使用吗?

我已阅读有关“-继续”标题的问题和答案。答案中给出的代码对我没有帮助。这就是我在这里发布后续问题的原因。

我想重新显示章节标题,但我使用的是长表。(我需要编写一个仅由长表组成的文档。我确实需要重新显示章节标题。在我的情况下,使用标题不起作用。)

我有一个长表 (至少) 超过两页。我想重新显示当前的节标题。我的问题是,长表与重新显示的节标题在同一行中继续。这是我使用的 latex 代码:

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{everyshi}% http://ctan.org/pkg/everyshi
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\usepackage{environ}% http://www.ctan.org/pkg/environ
\usepackage{longtable}

\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>
\newif\if@sectionpage %Conditional to see if we are on the page where a section has been started
\newif\if@tab@pagebreak %Conditional to check if a table will cause a pagebreak
\newdimen\currtabheight
\newdimen\pt@saved
  \let\ltx@tabular\tabular
  \let\ltx@endtabular\endtabular
  \providecommand{\env@tabular@save@env}{}
  \providecommand{\env@tabular@process}{}
%Patching the tabular envionment
\RenewEnviron{tabular}[1]{%
  \setbox0=\hbox{% measure the height of the tabular
    \ltx@tabular{#1}
      \BODY
    \ltx@endtabular
    }
  \currtabheight=\ht0 \advance\currtabheight by \dp0%
  \pt@saved=\the\pagetotal% store the current pagetotal value
  \advance\pt@saved by \currtabheight% add the height of the current tabular
  \ifdim\pt@saved>\pagegoal% the tabular will cause a pagebreak
    \global\@tab@pagebreaktrue
  \fi
  \ltx@tabular{#1}% printing the tabular
    \BODY
  \ltx@endtabular
  }
%Doing the old shipout trick with the addtional declared conditionals
\EveryShipout{%
  \ifdim\pagetotal>\pagegoal
    \if@sectionpage
      \if@tab@pagebreak\else\aftergroup\@section@title@\fi
    \else
      \aftergroup\@section@title@
    \fi
  \fi
  \global\@sectionpagefalse
  \global\@tab@pagebreakfalse}
%redefinition to make the sectionpage-switch work
\let\ltx@section=\section
\renewcommand{\section}{\@sectionpagetrue\ltx@section}
\makeatother

\begin{document}
\section{A section}

\lipsum[1-1]

 \begin{longtable}{|l| l|}
 KILLED & LINE!!!! \kill
 \caption[An optional table caption ...]{A long table\label{long}}\\
 \hline\hline
 \multicolumn{2}{@{*}c@{*}}%
 { This part appears at the top of the table}\\ \hline
 \endfirsthead
 \multicolumn{2}{@{*}c@{*}}%
 { This part appears at the top of every other page}\\ \hline\hline
 \endhead
 \endfoot
 \endlastfoot
 columns are specified& in the \\
 same way as in the tabular& environment.\\
 Lots of lines& like this.\\
 ...   
Lots of lines& like this.\\         
 \end{longtable}

\lipsum[2-2]

\section{Second section}

\begin{tabular}{l}
  AAAAAAAAAAAAAAAAAAAA \\
  AAAAAAAAAAAAAAAAAAAA \\
  AAAAAAAAAAAAAAAAAAAA \\
  AAAAAAAAAAAAAAAAAAAA \\
  AAAAAAAAAAAAAAAAAAAA \\
  AAAAAAAAAAAAAAAAAAAA
\end{tabular}

\lipsum[7-8]
\end{document}

如您所见,LaTeX 在标题连续行中开始长表的第二部分:

Longtable 的第二部分与重新显示的标题在同一行开始。

不幸的是,我对 LaTeX 了解不够,无法解决这个问题。有人能帮我吗?

(我已经看过这些类似问题的答案:

分页后重新显示章节标题

如何在分页符后生成“<section>继续”标题?

分页后重新显示章节标题(使用 titlesec)

答案1

头部的重新定义似乎没有帮助,但添加\pagestyle{headings}会将章节标题放在页面头部,即使在长表页面上也似乎解决了这个问题。

在此处输入图片描述

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum

\usepackage{longtable}

\pagestyle{headings}

\makeatother

\begin{document}
\section{A section}

\lipsum[1-1]

 \begin{longtable}{|l| l|}
 KILLED & LINE!!!! \kill
 \caption[An optional table caption ...]{A long table\label{long}}\\
 \hline\hline
 \multicolumn{2}{@{*}c@{*}}%
 { This part appears at the top of the table}\\ \hline
 \endfirsthead
 \multicolumn{2}{@{*}c@{*}}%
 { This part appears at the top of every other page}\\ \hline\hline
 \endhead
 \endfoot
 \endlastfoot
 columns are specified& in the \\
 same way as in the tabular& environment.\\
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
 Lots of lines& like this.\\   
Lots of lines& like this.\\         
 \end{longtable}

\lipsum[2-2]

\section{Second section}

\begin{tabular}{l}
  AAAAAAAAAAAAAAAAAAAA \\
  AAAAAAAAAAAAAAAAAAAA \\
  AAAAAAAAAAAAAAAAAAAA \\
  AAAAAAAAAAAAAAAAAAAA \\
  AAAAAAAAAAAAAAAAAAAA \\
  AAAAAAAAAAAAAAAAAAAA
\end{tabular}

\lipsum[7-8]
\end{document}

答案2

我在这个论坛上找到了一个解决方案(或更好的解决方法)具体的问题不是回答我关于长表问题之前的“部分继续”的问题。

我现在将整个部分放入超级标签环境中并更改运行头。如何执行此操作在此处解释:

更改 longtable(或其他“长表”包)中的运行头

我仍然对我的实际问题的答案感兴趣,因为将几个长表放在一个部分中似乎比用超级表包将所有内容放在一个长表中更干净。

我要感谢@Ulrike Fischer。她的评论让我再次审视了这个问题的解决方法。

(我将其作为答案发布,因为这似乎比使用评论功能更好。如果不是,请告诉我,我将删除此帖子。)

相关内容