I want to print a pgfplotstable where one column (which is not printed) used to change the style of another column. In my MWE below, I want to change the font=
style of select values in the Item
column if the highlight
column contains a value 1
. But in my actual use case, I will be changing a number of properties.
I have tried using \getthisrow
in preproc cell content/.code
, but in that context I get an "Undefined control sequence" error.
What else can I try?
Secondly, in preproc cell content/.code
I am attempting to change the font
, using \pgfplotstableset
, which does not seem to have any effect (otherwise the items in the "Not what I want"-table would all be orange).
\documentclass{standalone}
\usepackage{filecontents}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{color}
\begin{filecontents}{data.csv}
highlight,Item,Unrelated
1,Lorem,f
0,ipsum,o
0,dolor,o
1,sit,
0,amet,bar
\end{filecontents}
\begin{document}
\pgfplotstabletypeset[
col sep=comma,
columns={Item,Unrelated},
columns/Item/.style={string type},
columns/Unrelated/.style={string type},
every head row/.style={before row={
\textcolor{red}{Not what I want:}\\\toprule},
after row=\midrule},
every last row/.style={after row=\bottomrule},
preproc cell content/.code={
%\getthisrow{highlight}\highlight % <--Undefined control sequence
%use \highlight here to set pgf value
\pgfplotstableset{font=\color{orange}} % <--change styling for current cell (has no effect)
},
]{data.csv}
\pgfplotstabletypeset[
col sep=comma,
columns={Item,Unrelated},
columns/Item/.style={string type},
columns/Unrelated/.style={string type},
every head row/.style={before row={
\textcolor{green}{Desired result:}\\\toprule},
after row=\midrule},
every last row/.style={after row=\bottomrule},
]{
highlight,Item,Unrelated
1,\textcolor{orange}{Lorem},f
%color should be set by pgf key, not \textcolor
0,ipsum,o
0,dolor,o
1,\textcolor{orange}{sit},
%color should be set by pgf key, not \textcolor
0,amet,bar
}
\end{document}