1

I'm visualizing a csv file using pgfplotstable and longtable as followed:

\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}
}

I added a caption that shows up on every page. However it also shows up multiple times in my \listoftables. I'm assuming it's because pgfplotstable actually generates duplicates of the caption for every page. But how can I make it so it only shows up once in the list of tables?

Thanks!

After a lot of trying out different stuff, I found this to work:

\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}
}

Notice the use of \\[-23pt] in the style of every first row.

1 Answer 1

2
\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}
}

if you use the captioncommand on every page with \caption[]{#1} no entry in lot will be made. Only at the last row it will be done. therefor the tablelist list the table on the last page where the table is located.

I do not know for sure, if this solve the problem because you did not provide a Minimal Working Example. It is only a solution because of knowledge, untested.

6
  • @egreg you are right. Answer was edit just a few minutes ago. May 5, 2016 at 22:04
  • This almost worked! I had to change this line every last row/.style={after row=\caption{#1}\\\bottomrule}, (note the additional \\ before bottomrule). However, is it possible to get the page number to be the first page of the table?
    – The Oddler
    May 5, 2016 at 22:06
  • I tried using 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]{}\\} which almost works, only now I get an extra white space before the first row. But if I remove the \\ it won't build.
    – The Oddler
    May 5, 2016 at 22:13
  • @TheOddler try \newtabularline instead of \\ (maybe this helps) May 5, 2016 at 23:47
  • It is supposed to be \tabularnewline, but it gives the same problem. And using \kill does hide the row, but then the table doesn't shown in the lot anymore...
    – The Oddler
    May 6, 2016 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.