Here is the code I am working with:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{measurements.dat}
sample num-bugs num-part other-measure another
5 80 190 200 210
15 520 410 430 350
25 650 640 630 900
35 1100 1200 1150 1020
\end{filecontents}
\usepackage{pgfplots, pgfplotstable, booktabs, colortbl}
\pgfplotsset{compat=1.7}
\pgfplotstableset{
every head row/.style=
{before row={\toprule},
after row={\midrule}},
every last row/.style=
{after row={\bottomrule}},
every even row/.style=
{before row={\rowcolor[gray]{0.9}}},
columns/.style=
{dec sep align,
%column type=c
}
}
\begin{document}
\pgfplotstabletypeset[
columns={sample, another, num-part},
columns/sample/.style={
column name={Sample},
}
]{measurements.dat}
\end{document}
This results in the data being aligned at the decimal as expected.
However, the data is also aligned at l.
I need it to be aligned at c, so I add the option
columns/.style={column type=c}
(as commented-out above).
This generates the error:
ERROR: Extra alignment tab has been changed to \cr.
--- TeX said ---
<template> \endtemplate
l.31 ]{measurements.dat}
--- HELP ---
There are too many separate items (column entries) in a single row of
an array or tabular environment. In other words, there were too many &
's before the end of the row. You probably forgot the \\ at the end of
the preceding row.
How can I effect a centered and aligned column?
Example
Header1 Header2 LongerHeader3 HeaderWithoutARealName4
1.0 2.0 3.0 4.0
2.0 13.0 4 1234567890.23
Current left aligned outcome


dec sep alignintroduces two columns, one right-aligned, the other one left-aligned. And in fact, the decimal point is center-aligned (you just don’t have any decimals in your numbers). Thedec sep alignkey/algorithm is not very flexible. I would go with asiunitxsolution here, too. You may need to tell PGFmath/plotstable to not typeset numbers but leave them alone so thatsiunitxcan parse them, see an answer of mine that usessiunitxandpgfplotstable(look out forstring type). – Qrrbrbirlbel Oct 12 '13 at 20:46