Reference: My question which was answered by Dr. Christian Feuersänger Link to the question.. This is a follow-up question.
The MWE (Provided by Dr. Christian Feuersänger in his answer)
\documentclass{standalone}
\usepackage{pgfplotstable}
\begin{document}
\pgfplotstabletypeset[
col sep=comma,
columns/col1/.style={string type,column type=r},
columns/col2/.style={string type,column type=l},
columns/col3/.style={string type,column type=l},
]
{
col1,col2,col3
Col A,B,C
The first column,E,F
}
\end{document}
Question:
How to get a table having only two columns with second column having the elements
col2/col3
B/C
E/F
In detail, the table should be like this:
col1 col2/col3
Col A B/C
The first column E/F
How to get it using pgfplotstable?
Best Answer
In order to create a new column based on existing ones, you have to define the new column somehow. This involves three steps:
create one use
pgfplotstable
that it should be part of the output (and at which position) :columns
keycolumn/<name>/.style={...}
The new lines are those which refer to
mixed
(which is my name for the new column).The line
columns={col1,mixed}
tellspgfplotstable
that which columns should be typeset (and in which order), i.e. it fulfills step (2).The line
columns/mixed/.style=...
configures appearance options for columnmixed
(including its display name), i.e. it fulfills step (3).Finally, the
create on use/mixed/.style={...}
statement defines how to create the new column (step (1). In our case, we provide a/.code
fragment which uses two programming constructs to define the content: The line\edef\entry...
means "define\entry
to the expanded value in the braces (expanded def)". The\thisrow{colname}
statement expands to the value ofcolname
in the currently processed row (there is also\nextrow{colname}
and\prevrow{colname}
which operate in a similar way). Finally,\pgfkeyslet{.../next content}\entry
writes the value of\entry
into some value which is expected by thecreate col/assign
method as output.