2

I made this file parameters.dat:

parameter,    value
$K_1$,      0.00034
$K_2$,      0.0053
$K_3$,      0.07
$K_4$,      0.0027

Now I would like to generate a table in my .tex file with 4 columns: (1) Parameter; (2) Default value (the one from the .dat file); (3) Lower bound (0.75*value); (4) Upped bound (1.25*value). I tried with the following code but pdflatex gets stuck in an infinite loop:

\pgfplotstableset{
        create on use/lb/.style={
            create col/expr={\thisrow{value}*0.75}},
        create on use/ub/.style={
            create col/expr={\thisrow{value}*1.25}}
    }
    \pgfplotstabletypeset[
            col sep=comma,
        columns={parameter, value, lb, ub},
        columns/parameter/.style={
            column name={Parameter},
            string type
        }
        columns/value/.style={
            column name={Default Value}
        }
        columns/lb/.style={
            column name={Lower Bound}
        }
        columns/ub/.style={
            column name={Upper Bound}
        }
    ]
    {gfx/parameters.dat}
  • 1
    See the manual for create col on use for details for the new column creation. – percusse Oct 2 '13 at 8:32
  • I changed the code but pdflatex gets stuck in an infinite loop. I guess I'm forgetting some comma or semicolon somewhere... – remus Oct 2 '13 at 8:39
  • I think the problem is the way I define the parameter column... with math environment, e.g. $K_1$. – remus Oct 2 '13 at 8:51
5

parameters.dat:

parameter,  value
K_1,        0.00034
K_2,        0.0053
K_3,        0.07
K_4,        0.0027

Code:

        \pgfplotstableset{
            create on use/lb/.style={
                create col/expr={\thisrow{value}*0.75}},
            create on use/ub/.style={
                create col/expr={\thisrow{value}*1.25}}
        }
        \pgfplotstabletypeset[
            col sep=comma,
            columns={parameter, value, lb, ub},
            columns/parameter/.style={
                column name={Parameter},
                string type,
                preproc cell content/.append style={/pgfplots/table/@cell content/.add={$}{$}}
            },
            columns/value/.style={
                column name={Default Value}
            },
            columns/lb/.style={
                column name={Lower Bound}
            },
            columns/ub/.style={
                column name={Upper Bound}
            }
        ]{parameters.dat}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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