如何检索表格的标题(longtable)

如何检索表格的标题(longtable)

我想在不同的页面上重复标题longtable

  1. 有什么方法(除了定义一个新变量来保存标题)可以获取它吗?
  2. 我怎样才能去掉第一次标题后的多余行,即longtable第一页的页眉。

MWC(您可以替换图像):

\documentclass[preprint, 12pt]
\usepackage[table]{xcolor}   % colored rows
\usepackage{longtable}

\begin{document}
\begin{longtable}{|c|c|c|}
\caption{Step by step execution trace of Algorithm \ref{algo:CWM}}
\label{tab:example01Table}


% %\begin{tabular}{|c|c|c|}

%
\\       % <=====  I want to get rid of this line please 
\rowcolor{gray}
\# & Heap & Tour \\ 
\hline\hline
\endfirsthead
%
\multicolumn{3}{c}%
        {{(Cont.) Table \thetable: Step by step execution trace of Algorithm }} \\

\rowcolor{gray}
\# & Heap & Tour \\ 
\hline\hline
\endhead

%

0 &  Empty & \includegraphics[width=\mylength]{t00.pdf} \\\hline
1 & \includegraphics[width=\mylength]{h01.pdf} & \includegraphics[width=\mylength]{t01.pdf} \\ \hline
2 & \includegraphics[width=\mylength]{h02.pdf} & \includegraphics[width=\mylength]{t02.pdf} \\ \hline
3 & \includegraphics[width=\mylength]{h03.pdf} & \includegraphics[width=\mylength]{t03.pdf} \\ \hline
4 & \includegraphics[width=\mylength]{h04.pdf} & \includegraphics[width=\mylength]{t04.pdf} \\\hline
5 & \includegraphics[width=\mylength]{h05.pdf} & No Change \\ \hline
6 & \includegraphics[width=\mylength]{h06.pdf} & No Change \\ \hline
7 & \includegraphics[width=\mylength]{h07.pdf} & \includegraphics[width=\mylength]{t07.pdf} \\ \hline
8 & \includegraphics[width=\mylength]{h08.pdf} & No Change \\ \hline
9 & \includegraphics[width=\mylength]{h09.pdf} & \includegraphics[width=\mylength]{t09.pdf} \\\hline
10 & \includegraphics[width=\mylength]{h10.pdf} & \includegraphics[width=\mylength]{t10.pdf} \\ \hline
11 & \includegraphics[width=\mylength]{h11.pdf} & \includegraphics[width=\mylength]{t11.pdf} \\ \hline
- & - & \includegraphics[width=\mylength]{finalTour.pdf} \\ \hline

% %\end{tabular}

\end{longtable}
\end{document}

答案1

请始终发布最少的工作示例。

  1. 您可以加载nameref包,然后按如下方式使用它

    \multicolumn{3}{c}%
            {{(Cont.) Table \thetable: \nameref{tab:example01Table}}}
    
  2. 您可以加载该caption包并发出命令:

    \captionsetup[longtable]{aboveskip=0pt}
    

平均能量损失

\documentclass{article}
\usepackage[table]{xcolor}   % colored rows
\usepackage{longtable}
\usepackage[demo]{graphicx}

\usepackage{caption}
\captionsetup[longtable]{aboveskip=0pt}

\usepackage{nameref}

\begin{document}
\begin{longtable}{|c|c|c|}
\caption{Step by step execution trace of Algorithm \ref{algo:CWM}}
\label{tab:example01Table}


% %\begin{tabular}{|c|c|c|}

%
\\       % <=====  I want to get rid of this line please
\rowcolor{gray}
\# & Heap & Tour \\
\hline\hline
\endfirsthead
%
\multicolumn{3}{c}%
        {{(Cont.) Table \thetable: \nameref{tab:example01Table}}} \\

\rowcolor{gray}
\# & Heap & Tour \\
\hline\hline
\endhead

%

0 &  Empty & \includegraphics{t00.pdf} \\\hline
1 & \includegraphics{h01.pdf} & \includegraphics{t01.pdf} \\ \hline
2 & \includegraphics{h02.pdf} & \includegraphics{t02.pdf} \\ \hline
3 & \includegraphics{h03.pdf} & \includegraphics{t03.pdf} \\ \hline
4 & \includegraphics{h04.pdf} & \includegraphics{t04.pdf} \\\hline
5 & \includegraphics{h05.pdf} & No Change \\ \hline
6 & \includegraphics{h06.pdf} & No Change \\ \hline
7 & \includegraphics{h07.pdf} & \includegraphics{t07.pdf} \\ \hline
8 & \includegraphics{h08.pdf} & No Change \\ \hline
9 & \includegraphics{h09.pdf} & \includegraphics{t09.pdf} \\\hline
10 & \includegraphics{h10.pdf} & \includegraphics{t10.pdf} \\ \hline
11 & \includegraphics{h11.pdf} & \includegraphics{t11.pdf} \\ \hline
- & - & \includegraphics{finalTour.pdf} \\ \hline

% %\end{tabular}

\end{longtable}
\end{document} 

输出:

在此处输入图片描述

答案2

包裹namerefzreftitleref记住标题:

\documentclass{article}
\usepackage{longtable}
\usepackage{caption}
\captionsetup[longtable]{aboveskip=0pt}

\usepackage{nameref}
\usepackage{zref-titleref, zref-user}

\begin{document}
  \begin{table}
    \centering
    \caption{Table caption}\label{tab}\zlabel{tab}
  \end{table}

  \begin{longtable}{lll}
    \caption{Longtable caption}\label{longtab}\zlabel{longtab}\\
    nameref:& \nameref{tab} & \nameref{longtab}\\
    ztitleref:& \ztitleref{tab} & \ztitleref{longtab}
  \end{longtable}
\end{document}

结果

评论:

相关内容