0

It seems, that string replace={XXX}{replaced} does not work, if I use postproc cell content/.style={...}.
What can I do?

enter image description here

\documentclass[a4paper]{article}
\usepackage{colortbl}
\usepackage{pgfplotstable}
\pgfplotsset{compat=newest}
\pgfplotstableread[col sep = semicolon, header=true]{
A;     B
111; aaa
222; XXX
333; ccc
444; ddd
555; XXX
}{\mytable}

\begin{document}

\section{With postproc cell content -- works not}
\pgfplotstabletypeset[string type,
columns/B/.style={
string replace={XXX}{replaced}, 
postproc cell content/.style={
  @cell content={\cellcolor{pink}\textcolor{blue}{##1}}   },
},
]{\mytable}

\section{Without postproc cell content -- works}
\pgfplotstabletypeset[string type,
columns/B/.style={
string replace={XXX}{replaced}, 
},
]{\mytable}
\end{document}

1 Answer 1

2

Just replace the string as part of postproc cell content:

\documentclass[a4paper]{article}
\usepackage{colortbl}
\usepackage{pgfplotstable}
\pgfplotsset{compat=newest}
\pgfplotstableread[col sep = semicolon, header=true]{
A;     B
111; aaa
222; XXX
333; ccc
444; ddd
555; XXX
}{\mytable}

\ExplSyntaxOn
\cs_new_eq:NN \strifeq \str_if_eq:nnTF
\ExplSyntaxOff

\begin{document}

\section{With postproc cell content -- works not}
\pgfplotstabletypeset[string type,
columns/B/.style={
string replace={XXX}{replaced}, 
postproc cell content/.style={
  @cell content={\cellcolor{pink}\textcolor{blue}{##1}}   },
},
]{\mytable}

\section{Without postproc cell content -- works}
\pgfplotstabletypeset[string type,
columns/B/.style={
string replace={XXX}{replaced}, 
},
]{\mytable}

\section{With postproc cell content -- works}
\pgfplotstabletypeset[string type,
columns/B/.style={
postproc cell content/.style={
  @cell
  content={\cellcolor{pink}\textcolor{blue}{\strifeq{##1}{XXX}{replaced}{##1}}}},
},
]{\mytable}
\end{document}

enter image description here

2
  • Ok, this hack works. For theoretical interests it could be intresting, how to use pgfplotstable's function string replace={XXX}{replaced} anyway.
    – cis
    Jun 6, 2021 at 14:57
  • @cis I have no idea, I don't use pgfplotstable myself.
    – Skillmon
    Jun 6, 2021 at 15:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .