# How to vertically align text in the headers of a PgfplotsTable?

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.

-
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 '12 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 '12 at 14:06

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}

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

\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[
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 last row/.style={after row=\bottomrule},

• to use \pgfkeyssetvalue in assign column name/.code, and
• the additional \\ line break in after row in the every head row style.
Looks good! I would probably use \shortstack{Instance\\Size} instead of the \textstackrel macro. –  Jake Dec 15 '12 at 14:46