1

I am stacking one header by using this macro: \newcommand*{\textstackrel}[2]{\ensuremath{\stackrel{\hbox{#1}}{\hbox{#2}}}}. This makes the other single line headers bottom aligned, which looks bad.

So I tried a few multirow tricks I know to no avail, e.g.: assign column name/.code={\multicolumn{1}{c}{\multirow{2}{*}{#1}}}

Most of the time I ran into this error message:

! siunitx error: "duplicate-exponent-token"
! Duplicate exponent marker token '\token_to_str:N d' in input.

How do I do this correctly?

PS: MWE will follow when I have (more) time and if there is no answer before that.

2
  • I think you do need to provide some more information: Why do you get siunitx errors if you're not using the S column type?
    – Jake
    Dec 14, 2012 at 7:06
  • The column types for the actual cells are of course S. Unfortunately I can not reproduce the error I had. On the positive side, I will post a solution for the original problem in a few :)
    – stefanct
    Dec 15, 2012 at 14:06

1 Answer 1

3

While preparing the MWE I have found a possible solution. Feel free to improve it or post another one.

\documentclass{article}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{siunitx}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}

\pgfplotstableread{
size        min         max         avg         med
1           2e-03       3e-03       2.5e-03     2.4e-03
10          2.02e-03    3.02e-03    2.72e-03    2.32e-03
123456789   2.02        123.72e9    2.72e9      2.32e-03
}{\loadedtable}

\pgfplotstableset{
    begin table=\begin{longtable},
    end table=\end{longtable},
}
\sisetup{
    table-format = 3.2e+3,
    round-precision=2,
    round-mode=places,
    scientific-notation=engineering,
    group-digits=integer,
    group-separator={,},
    exponent-product = \cdot,
}

\pgfplotstabletypeset[
    header=true,
    string type,
    multicolumn names,
    columns={size,med,min,avg,max},
    assign column name/.code={%
        \pgfkeyssetvalue{/pgfplots/table/column name}{\multicolumn{1}{c}{\multirow{2}{*}{#1}} }%
    },
    columns/size/.style ={column name={\shortstack{Instance\\Size}}, column type={S[scientific-notation=false,table-format=9]}, int detect},
    columns/min/.style ={column name=Minimum,   column type=S},
    columns/avg/.style ={column name=Average,   column type=S},
    columns/med/.style ={column name=Median,    column type=S},
    columns/max/.style ={column name=Maximum,   column type=S},
    every head row/.style={before row=\toprule, after row=\\\midrule\endhead},
    every last row/.style={after row=\bottomrule},
]{\loadedtable}

\end{document}

The important bits are:

  • to use \pgfkeyssetvalue in assign column name/.code, and
  • the additional \\ line break in after row in the every head row style.

1
  • 1
    Looks good! I would probably use \shortstack{Instance\\Size} instead of the \textstackrel macro.
    – Jake
    Dec 15, 2012 at 14:46

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.