带有标题的 pgfplotstable 和 longtable 在表格列表中多次显示

带有标题的 pgfplotstable 和 longtable 在表格列表中多次显示

我正在使用 pgfplotstable 和 longtable 可视化一个 csv 文件,如下所示:

\newcommand{\powerTable}[3]{
    \pgfplotstabletypeset[
        string type,
        col sep = comma,
        skip rows between index={0}{#2},
        skip rows between index={#3}{1000000000},
        begin table=\begin{longtable},
        end table=\end{longtable},
        % packo id,N,Packomania Radius,,id,circlecount,Radius,time (ns),overlap (square units),nancount,Time,,Difference,% Increase
        columns={{N},{ratio},{Radius},{Difference},{Increase},{Time}},
        every head row/.style={before row=\caption{#1}\\\toprule, after row=\midrule\endhead},
        every last row/.style={after row=\bottomrule},
        column type={l}, %default
        columns/{N}/.style={column type={c}},
        columns/{ratio}/.style={column name={Beste radius}},
        columns/{Radius}/.style={column name={Radius}},
        columns/{Difference}/.style={column name={Vergroting}},
        columns/{Increase}/.style={column type={c}, column name={Vergroting (\%)}},
        columns/{Time}/.style={column name={Tijd}},
    ]{csv/Power Packomania Problems Comparison.csv}
}

我添加了一个显示在每一页上的标题。但是它也在我的 中出现了多次\listoftables。我猜是因为 pgfplotstable 实际上为每一页生成了标题的副本。但是我怎样才能让它只在表格列表中出现一次呢?

谢谢!

尝试了很多不同的东西后,我发现这个有效:

\newcommand{\powerTable}[3]{
    \pgfplotstabletypeset[
        string type,
        col sep = comma,
        skip rows between index={0}{#2},
        skip rows between index={#3}{1000000000},
        begin table=\begin{longtable},
        end table=\end{longtable},
        % packo id,N,Packomania Radius,,id,circlecount,Radius,time (ns),overlap (square units),nancount,Time,,Difference,% Increase
        columns={{N},{ratio},{Radius},{Difference},{Increase},{Time}},
        every head row/.style={before row=\caption[]{#1}\\\toprule, after row=\midrule\endhead},
        every last row/.style={after row=\bottomrule},
        every first row/.style={before row=\captionsetup{labelformat=empty}\caption[#1]{}\\[-23pt]},
        column type={l}, %default
        columns/{N}/.style={column type={c}},
        columns/{ratio}/.style={column name={Beste radius}},
        columns/{Radius}/.style={column name={Radius}},
        columns/{Difference}/.style={column name={Vergroting}},
        columns/{Increase}/.style={column type={c}, column name={Vergroting (\%)}},
        columns/{Time}/.style={column name={Tijd}},
    ]{csv/Power Packomania Problems Comparison.csv}
}

\\[-23pt]注意每个第一行的样式的用法。

答案1

\newcommand{\powerTable}[3]{
    \pgfplotstabletypeset[
        string type,
        col sep = comma,
        skip rows between index={0}{#2},
        skip rows between index={#3}{1000000000},
        begin table=\begin{longtable},
        end table=\end{longtable},
        % packo id,N,Packomania Radius,,id,circlecount,Radius,time (ns),overlap (square units),nancount,Time,,Difference,% Increase
        columns={{N},{ratio},{Radius},{Difference},{Increase},{Time}},
        every head row/.style={before row=\caption[]{#1}\\\toprule, after row=\midrule\endhead},
        every last row/.style={after row=\caption{#1}\bottomrule},
        column type={l}, %default
        columns/{N}/.style={column type={c}},
        columns/{ratio}/.style={column name={Beste radius}},
        columns/{Radius}/.style={column name={Radius}},
        columns/{Difference}/.style={column name={Vergroting}},
        columns/{Increase}/.style={column type={c}, column name={Vergroting (\%)}},
        columns/{Time}/.style={column name={Tijd}},
    ]{csv/Power Packomania Problems Comparison.csv}
}

如果您在每一页上使用 \caption[]{#1} 的 captioncommand,则不会进行批量输入。只有在最后一行才会进行批量输入。因此,tablelist 会在表格所在的最后一页列出表格。

我不确定这是否能解决问题,因为您没有提供最小工作示例。这只是一个基于知识的解决方案,未经测试。

相关内容