多列不计算 pgfplotstable 中的列属性

多列不计算 pgfplotstable 中的列属性

考虑以下 MWE,我希望跨越/组合multicolumn中的列数。pgfplotstablelongtable

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

根据提供的文件,列数应为四,.csvmulticolumn除非我输入,否则无法正确跨越

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

这是输出,显然没有右对齐跨越所有列。我做错了什么?

在此处输入图片描述

\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

如果你添加如下一行

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

然后你会看到

在此处输入图片描述

显示十进制对齐在内部使用两列,您需要考虑到这一点。(或者您可以使用dcolumn使用单列的十进制对齐)

相关内容