# Aligning Tuples of Decimals with PgfplotsTable

In this question, Jake gave an awesome answer that shows how PgfplotsTable can be used to read tab-delimited data from a file, and typeset the parsed decimals in scientific notation such that all of the decimals in a column are aligned at the decimal point. Here's a picture that shows what I mean.

Can Jake's solution be generalized to allow for tuples of decimals? More specifically, suppose I wish to typeset a table of numeric data, some of which are vectors that I would like to represent as tuples. All of the decimals, including the components of the tuples, are recorded in a tab-delimited text file. Here is a sample text file.

Iteration   x_1 x_2
1   13.44   0.0000000448
2   1232.1249   -393.0000424
3   0.01    1


I would like to output to look like the image below.

Edit

I realized that placing an entire tuple under one column may not be a good idea, as this leads to unnecessary clutter that makes the table harder to read. See my partial answer for more information, and additional problems that may arise due to the nature of the data.

Thanks for your help!

-

I have a partial solution here, as I did not implement the functionality to parse the input from a file. After looking at the output, however, I would probably recommend that the components vectors be typeset in separate columns. The commas (and possibly parenthesis and transpose superscript) add a lot of visual clutter to the table. Instead of creating one column called $\mathbf{x}$, I would create one column for each component of the vector (e.g. $x_1$, ..., $x_n$). This also simplifies the LaTeX code considerably.

Here is the an image of the kind of output I was looking for, along with the code. To get the parenthesis flush with the decimals, you need to tinker around with the table-format option of siunitx. This leads to aesthetic problems if some numbers in the leftmost position are prefixed with negative signs and others are not. For the numbers not prefixed with a sign, there would be gaps between the left parenthesis and the integer part of the decimal.

\documentclass[11pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
\begin{tabular}{
S
@{(}
S[round-mode=figures, round-precision=4, scientific-notation=true, table-format=1.3e-1]@{,\ }
S[round-mode=figures, round-precision=4, scientific-notation=true, table-format=-1.3e-1]
@{$)^t$}
}
\toprule
\multicolumn{1}{c}{$k$} & \multicolumn{2}{c}{$\mathbf{x_k}$} \\
\midrule
1 & 13.44 & 0.00000004448 \\
2 & 1232.1249 & -393.0000424 \\
3 & 0.1 & 1 \\
\bottomrule
\end{tabular}
\end{document}


-