是否可以定义一个multicolumn{}{}{}
命令,它自动地跨度所有列一张桌子?
对于我的长表,我想使用在序言中定义的命令,该命令在右下边缘(raggedleft)排版一条消息,表明该表将在下一页继续。
由于我的长表的列数不同,我不知道如何定义该通用命令。是否有一个计数器可以读取实际表的列数并可以使用?
编辑:我发现长桌包手册有一个内部计数器\LT@cols
但我不知道如何将它用于多列命令——我甚至无法在文档中打印它的值。
编辑 3:使用 Herbert 的代码就可以工作。
\makeatletter
\def\LongtableFooter{%
\multicolumn{\LT@cols}{r}{\scriptsize to be continued on following page}\\}
\makeatother
例子:
(备注:由于示例中的第二个 longtable 只有 4 列,因此命令\multicolumn{5}
自然失败。)
\documentclass[]{scrbook}
\usepackage{booktabs, longtable}
%\newcommand{\LongtableFooter}{\multicolumn{5}{r}\mbox{to be continued on following page}}
\makeatletter
\def\LongtableFooter{%
\multicolumn{\LT@cols}{r}{\scriptsize to be continued on following page}\\}
\makeatother
\begin{document}
here comes the table with the pagebreak
\vspace{0.6\textheight}
\begin{longtable}{p{2cm}p{2cm}p{2cm}ll}
\toprule
A & B & C & D & E\\
\midrule
\endfirsthead
\mbox{table continued from last page}\\
\toprule
A & B & C & D\\
\midrule
\endhead
%\bottomrule
\LongtableFooter
\endfoot
\bottomrule
\endlastfoot
a & b & c & d\\
\midrule
a & b & c & d\\
& b & c & d\\
& b & c & d\\*
\midrule
a & b & c & d\\
& b & c & d\\
& b & c & d\\*
\midrule
a & b & c & d\\
& b & c & d\\
& b & c & d\\*
\midrule
a & b & c & d\\
& b & c & d\\
& b & c & d\\
\midrule
a & b & c & d\\
& b & c & d\\
& b & c & d\\
\midrule
a & b & c & d\\
& b & c & d\\
& b & c & d\\
\end{longtable}
And here it fails, as there are only 4 columns:
\begin{longtable}{p{2cm}p{2cm}p{2cm}ll}
\toprule
A & B & C & D\\
\midrule
\endfirsthead
\mbox{table continued from last page}\\
\toprule
A & B & C & D\\
\midrule
\endhead
%\bottomrule
\LongtableFooter
\endfoot
\bottomrule
\endlastfoot
a & b & c & d\\
& b & c & d\\
& b & c & d\\
& b & c & d\\
& b & c & d\\
& b & c & d\\*
\midrule
a & b & c & d\\
& b & c & d\\
& b & c & d\\*
\midrule
a & b & c & d\\
& b & c & d\\
& b & c & d\\*
\midrule
a & b & c & d\\
& b & c & d\\
& b & c & d\\*
\midrule
a & b & c & d\\
& b & c & d\\
& b & c & d\\*
\midrule
a & b & c & d\\
& b & c & d\\
& b & c & d\\*
\midrule
a & b & c & d\\
& b & c & d\\
& b & c & d\\
\midrule
a & b & c & d\\
& b & c & d\\
& b & c & d\\
\midrule
a & b & c & d\\
& b & c & d\\
& b & c & d\\
\midrule
a & b & c & d\\
& b & c & d\\
& b & c & d\\
\end{longtable}
\end{document}
\end{document}
答案1
尝试这个:
\makeatletter
\def\LongtableFooter{%
\multicolumn{\LT@cols}{r}{to be continued on following page}\\}
\makeatother