I'm using pgfplotstable to create tables from .csv-files. But when I use postproc cell content
to change the appearence of a specific cell, all former formatting of this cell seems to be ignored. How can I make changes to the appearence of a specific cell and at the same time preserve a uniform styling of the table?
Here is the MWE:
\documentclass{article}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{pgfplotstable}
%Make rows higher:
\setlength\extrarowheight{1.4pt}
%GLOBAL FORMATING:
\pgfkeys{/pgf/number format/.cd,
use comma,
1000 sep={}}
\usepackage{lipsum}
\usepackage{filecontents}
\begin{filecontents}{data.csv}
Name,1,2
A,10.23,3.23
B,11.23,4.23
C,12.23,5.23
D,13.23,6.23
E,14.23,7.23
F,15.23,8.23
\end{filecontents}
\begin{document}
\lipsum[1]
\begin{table}[!htb]
\centering
\caption{Some text describing the table}
\pgfplotstabletypeset[col sep=comma,
columns={Name, 1, 2},% <---these columns will appear in the table
%------------------TYPESETTING COLUMNS:-------------------------------
columns/Name/.style={% <---style column "Name"
string type,%
column type/.add={}{|},%
},
%
columns/1/.style={% <---style column "1"
column name=I,
precision=1,column type/.add={}{|},%
},
%
columns/2/.style={% <---style column "2"
column name=II,
precision=1, column type/.add={}{},%
postproc cell content/.code={% <--- style row 2 (=index 1) of column "2"
\ifnum\pgfplotstablerow=1
\pgfkeysalso{@cell content=\textcolor{red!100}{##1}}% <---make it red
\fi
},
},
%
%------------------TYPESETTING ROWS-------------------------------
every head row/.style={before row=\toprule, after row=\midrule},%
every last row/.style={after row=\bottomrule}%
]%
{data.csv}
\end{table}
\lipsum[2]
\end{document}
And this is, what it looks like:
I would like to have the cell containing 4.23
to contain 4,2
, so that it is formatted as all the other cells.
Thank you very much in advance!
##1
is a shortcut to the value@preprocessed cell content
. In this context you need@cell content