0

Consider the following MWE where I would expect the multicolumn to span the number of columns in the pgfplotstable/longtable combination.

\multicolumn{\pgfplotstablecols}{r}{{\small\tablename\ \thetable{} -- will continue.}}    

The number of columns should be four, according to the supplied .csv file, but somehow multicolumn doesn't span properly unless i type

\multicolumn{6}{r}{{\small\tablename\ \thetable{} -- will continue.}}

This is the output, which obviously isn't aligned to the right spanning all columns. What am I doing wrong?

enter image description here

\documentclass[a5paper,12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\usepackage{pgfplotstable,booktabs,longtable}
\usepackage{siunitx,filecontents}
\pgfplotsset{compat=newest,
/pgf/number format/.cd,
        use comma,}
\pgfplotstableset{
begin table=\begin{longtable},
end table=\end{longtable},
}
\sisetup{exponent-product = {\cdot},output-decimal-marker={,}, per-mode=symbol}

\begin{filecontents}{table.csv}
Period;     M1;     M2;     M3
a;        9,4;    1706;   1706
b;        9,2;    1135;   2841
c;        9,4;    1319;   4160
d;        9,4;    1525;   5685
e;        9,2;    1367;   7052
f;        9,5;    1261;   8313
g;        9,3;    1814;   10127
h;        9,2;    1450;   1157
a;        9,4;    1706;   1706
b;        9,2;    1135;   2841
c;        9,4;    1319;   4160
d;        9,4;    1525;   5685
e;        9,2;    1367;   7052
f;        9,5;    1261;   8313
g;        9,3;    1814;   10127
h;        9,2;    1450;   1157
a;        9,4;    1706;   1706
b;        9,2;    1135;   2841
c;        9,4;    1319;   4160
d;        9,4;    1525;   5685
e;        9,2;    1367;   7052
f;        9,5;    1261;   8313
g;        9,3;    1814;   10127
h;        9,2;    1450;   1157
a;        9,4;    1706;   1706
b;        9,2;    1135;   2841
c;        9,4;    1319;   4160
d;        9,4;    1525;   5685
e;        9,2;    1367;   7052
f;        9,5;    1261;   8313
g;        9,3;    1814;   10127
h;        9,2;    1450;   11577
\end{filecontents}

\begin{document}

{\centering
\pgfplotstabletypeset[%
    col sep=semicolon,
    read comma as period=true,
    header=true,
    every head row/.style={
        before row={%
            \caption{Some caption}%
            \label{tab:sometable}\tabularnewline\toprule%
        }, % before row
        after row={\midrule\endhead\midrule\multicolumn{\pgfplotstablecols}{r}{{\small\tablename\ \thetable{} -- will continue.}}\endfoot
        \bottomrule\endlastfoot%
        }, % after row
    }, % every head row
    display columns/0/.style={column type={l},string type},
    display columns/1/.style={string type, column type={S[table-format=2.2, add-decimal-zero=true]}},
    display columns/2/.style={sci,sci zerofill,sci sep align,},
    display columns/3/.style={sci,sci zerofill,sci sep align,},
]{table.csv}\par
}

\end{document}
1

If you add a line like

        after row={
a&b&c&d&e&f\\
\midrule\endhead\midrule\multicolumn{\pgfplotstablecols}{r}{{\small\tablename\ \thetable{} -- will continue.}}\endfoot
        \bottomrule\endlastfoot%
        }, % after row

then you see

enter image description here

Showing that the decimal alignment is using two columns internally which you need to take account of. (Or you could perhaps use dcolumn decimal alignment which uses a single column)

  • Aha! Where should I have spotted this before? :-) Moving the before and after row after the display columns statements did the trick! – Holene Feb 2 '16 at 17:03

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.