Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

Table of Decimals

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.

enter image description here


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!

share|improve this question
add comment

1 Answer

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.


    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]
\multicolumn{1}{c}{$k$} & \multicolumn{2}{c}{$\mathbf{x_k}$} \\
1 & 13.44 & 0.00000004448 \\
2 & 1232.1249 & -393.0000424 \\
3 & 0.1 & 1 \\

enter image description here

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.