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.

I would like to use pgfplotstable to typeset some numbers stored in a text file. I have used \pgfplotstableread to achieve that and it worked all right. Now I want to add a column to the said table that contains literal entries, or more precisely mathematical entries. I think I should use something like create on use or \pgfplotstablecreatecol but I am a little confused about how to actually do it. Do you know how I could transform this

enter image description here

into this

enter image description here

The previous picture were obtained with the following code :

\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{array}
\usepackage{colortbl}

\begin{document}

\begin{table}
\centering
\begin{tabular}{cccccc}\toprule
         & $c_0$     & $c_1$ \\    
$u \times 10^2$ & -3.8682 & 1.5055   \\
$v \times 10^6$ & 2.1272  & -8.3619  \\
$w \times 10^3$ & 1.1862  & -4.6269  \\\bottomrule
\end{tabular}
\caption{It should eventually look like this.}
\end{table}

\begin{table}

\pgfplotstableread{
-3.8682 1.5055
2.1272 -8.3619
1.1862 -4.6269
}\tabledon

  \centering
\pgfplotstabletypeset[header=false,
every head row/.style={
before row={%
\toprule}},
every last row/.style={
after row=\bottomrule},
display columns/0/.style={column name={$c_0$}},
display columns/1/.style={column name={$c_1$}},
/pgf/number format/precision=4,
columns
]{\tabledon}
\caption{This is my current attempt.}
\end{table}

\end{document}
share|improve this question
    
If you load a table from a file, do you know how many rows are there? Where do you get to know what should be in the inserted column - from another file, or are there exactly 3 rows always and you know they should be marked this way? –  yo' Aug 27 '12 at 18:33
    
I know the number of rows and exactly what should go in every cell of the first column. –  Alfred M. Aug 28 '12 at 6:13

1 Answer 1

up vote 3 down vote accepted

You can use the create col/set list style for supplying the list of cells:

\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{booktabs}

\begin{document}

\pgfplotstableread{
-3.8682 1.5055
2.1272 -8.3619
1.1862 -4.6269
}\tabledon

\pgfplotstabletypeset[
    header=false,
    every head row/.style={
        before row={%
            \toprule
        }
    },
    every last row/.style={
        after row=\bottomrule
    },
    display columns/0/.style={column name={}},
    display columns/1/.style={column name={$c_0$}},
    display columns/2/.style={column name={$c_1$}},
    /pgf/number format/precision=4,
    create on use/newcol/.style={
        create col/set list={$u \times 10^2$,$v \times 10^6$,$w \times 10^3$}
    },
    columns/newcol/.style={string type},
    columns={newcol,0,1}
]{\tabledon}

\end{document}
share|improve this answer
1  
thanks for your answer, that was very useful! –  Denis Jul 14 at 13:39

Your Answer

 
discard

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.