I’m working on a paper in which I present numerous big tables, all of which should be formatted in the same way. In every table, some entries should be highlighted, e.g. typeset bold. So I want to define a common style and locally specify which cells to highlight.
I have tried various methods, all of which fail in one way or another:
\documentclass{article}
\usepackage{pgfplotstable}
\pgfplotsset{compat=newest}
% common style
\pgfplotstableset{mystyle/.style={
columns/rownb/.style = {
column name = {{\#}},
dec sep align,
fixed
}
}}
% common style
\pgfplotstableset{myotherstyle/.style={
columns/rownb/.style = {
column name = {{\#}},
dec sep align,
fixed
},
otherhighlight/.style = {
postproc cell content/.append code=\pgfkeysalso{@cell content=\emph{##1}}
},
every row 1 column rownb/.append style={otherhighlight},
every row 4 column rownb/.append style={otherhighlight}
}}
\begin{document}
% This is how I would like to do it, i.e. local specification of the
% cells to be highlighted
\pgfplotstabletypeset[mystyle,
highlight/.style = {
postproc cell content/.append code=\pgfkeysalso{@cell content=\textbf{##1}}
},
every row 1 column rownb/.append style={highlight},
every row 4 column rownb/.append style={highlight}]{
rownb xs
1 11
2 22
3 33
4 44
5 55
6 66
}
\pgfplotstabletypeset[myotherstyle]{
rownb xs
1 11
2 22
3 33
4 44
5 55
6 66
}
\end{document}
This yields the two tables:
# xs
1 11
**22** 22
3 33
4 44
**55** 55
6 66
# xs
1 11
22
3 33
4 44
55
6 66
Here **55**
means bold. In the first table the content of the cells to be highlighted gets duplicated. In the second table the content vanishes.
Edit 1: The first approach works, if the column has string type
. I vaguely remember that for each column of numeric type pgfplotstable creates an additional column to align numbers properly. So apparently this causes the post-processing to duplicate cell contents. Still, I would like to work it for my case.