使用带有 \cmidrule 的 longtable:分页问题

使用带有 \cmidrule 的 longtable:分页问题

这是一个(最小的?)工作示例,说明了我遇到的两个问题:

\documentclass{article}
\usepackage{longtable,booktabs,lipsum,array}
\usepackage{pgfplots}
\newcommand{\sheaf}{\mathcal}
\begin{document}
\begin{longtable}{>{\raggedright}m{2.5in} c c c c c c c}
\caption{Degree 8 curves\label{table:degree_8}}\\ \toprule 
Rational curve: \\$[t,s] \mapsto$ & $\sheaf E_{1} |_C$ & $\sheaf E_{2} |_C$ & $\sheaf E_{3} |_C$ & $\sheaf E_{4} |_C$ & $\sheaf E_{5} |_C$ & $\sheaf E_{6} |_C$\\ \midrule 
\endfirsthead
\caption[]{Degree 8 curves (continued)}\\ \toprule 
Rational curve: \\$[t,s] \mapsto$ & $\sheaf E_{1} |_C$ & $\sheaf E_{2} |_C$ & $\sheaf E_{3} |_C$ & $\sheaf E_{4} |_C$ & $\sheaf E_{5} |_C$ & $\sheaf E_{6} |_C$\\ \midrule 
\multicolumn{1}{c}{\vdots} & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\ \cmidrule{2-7} 
\endhead
\multicolumn{1}{c}{\vdots} & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots\\ \bottomrule
\endfoot
\endlastfoot
\pgfplotsforeachungrouped \i in {0,...,22}
{
    \lipsum[\i] & $\Sigma$ & $\Sigma$ & $\Sigma$ & $\Sigma$ & $\Sigma$ & $\Sigma$ \\
    \cmidrule{2-7}
}
\lipsum[1] & $\Sigma$ & $\Sigma$ & $\Sigma$ & $\Sigma$ & $\Sigma$ & $\Sigma$ \\ \bottomrule
\end{longtable}
\end{document}

我甚至不想尝试发布图片,但存在以下问题:

  1. 在第一页(以及此后的几乎每一页), 都\cmidrule位于页脚之前。我希望\cmidrule将 全部删除。有什么办法可以解决这个问题吗?
  2. 第 13 页末尾\cmidrule的 被推到了第 14 页,产生了明显不想要的效果。假设我的第一个请求不可行,有没有办法纠正这个问题(不涉及手动调整分页符,这有点违背了使用 的整个目的longtable)?

答案1

这将删除\cmidrule分页符。

\documentclass{article}
\usepackage{longtable,booktabs,lipsum,array}
\usepackage{pgfplots}
\newcommand{\sheaf}{\mathcal}
\makeatletter

\def\LT@output{%
  \ifnum\outputpenalty <-\@Mi
    \ifnum\outputpenalty > -\LT@end@pen
      \LT@err{floats and marginpars not allowed in a longtable}\@ehc
    \else
      \setbox\z@\vbox{\unvbox\@cclv}%
      \ifdim \ht\LT@lastfoot>\ht\LT@foot
        \dimen@\pagegoal
        \advance\dimen@-\ht\LT@lastfoot
        \ifdim\dimen@<\ht\z@
          \setbox\@cclv\vbox{\unvbox\z@
\copy\LT@foot\vss}%
          \@makecol
          \@outputpage
          \setbox\z@\vbox{\box\LT@head}%
        \fi
      \fi
      \global\@colroom\@colht
      \global\vsize\@colht
      \vbox
        {\unvbox\z@
\box\ifvoid\LT@lastfoot\LT@foot\else\LT@lastfoot\fi}%
    \fi
  \else
    \setbox\@cclv\vbox{\unvbox\@cclv
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbox0\lastbox
\ifdim\ht0=0.29999pt \unskip % hope that was a cline we threw away
\else
\nointerlineskip
\box0     % put it back, whatever it was
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\copy\LT@foot\vss}%
    \@makecol
    \@outputpage
      \global\vsize\@colroom
    \copy\LT@head\nobreak
  \fi}


\makeatother

\begin{document}
\LTleft-20pt 
\LTright-20pt plus \fill
\begin{longtable}{>{\raggedright}m{2.5in} c c c c c c c}
\caption{Degree 8 curves\label{table:degree_8}}\\ \toprule 
Rational curve: \\$[t,s] \mapsto$ & $\sheaf E_{1} |_C$ & $\sheaf E_{2} |_C$ & $\sheaf E_{3} |_C$ & $\sheaf E_{4} |_C$ & $\sheaf E_{5} |_C$ & $\sheaf E_{6} |_C$\\ \midrule 
\endfirsthead
\caption[]{Degree 8 curves (continued)}\\ \toprule 
Rational curve: \\$[t,s] \mapsto$ & $\sheaf E_{1} |_C$ & $\sheaf E_{2} |_C$ & $\sheaf E_{3} |_C$ & $\sheaf E_{4} |_C$ & $\sheaf E_{5} |_C$ & $\sheaf E_{6} |_C$\\ \midrule 
\multicolumn{1}{c}{\vdots} & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\ \cmidrule{2-7} 
\endhead
\multicolumn{1}{c}{\vdots} & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots\\ \bottomrule
\endfoot
\endlastfoot
\pgfplotsforeachungrouped \i in {0,...,22}
{
    \lipsum[\i] & $\Sigma$ & $\Sigma$ & $\Sigma$ & $\Sigma$ & $\Sigma$ & $\Sigma$ \\
    \cmidrule{2-7}
}
\lipsum[1] & $\Sigma$ & $\Sigma$ & $\Sigma$ & $\Sigma$ & $\Sigma$ & $\Sigma$ \\ \bottomrule
\end{longtable}
\end{document}

相关内容