I want a way to automatically (post-)process the minimum of every n rows in a column as bold.
So if my table had L rows, I want to group a column by each group of n (assumes L % n == 0) and bold the minimum value of each group.
In pseudocode:
for i in 0 to (L//n)-1:
idx = idxmin(row[i*n], row[i*n+1], row[i*n+2], ..., row[i*n+n-1])
bold(row[idx])
So far the closest answer I've found is this answer that bolds the maximum value of all rows in a column, it was easy to modify this to bold the minimum value but I couldn't get beyond that.
This is a minimal working example (L==9, n=3). I want the third, sixth, and eigth value in column b bolded, not just the global minium (sixth value):
\documentclass[12pt]{article}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\newcommand{\findmin}[3]{
\pgfplotstablevertcat{\datatable}{#1}
\pgfplotstablecreatecol[create col/expr={\pgfplotstablerow}]{rownumber}\datatable
\pgfplotstablesort[sort key={#2},sort cmp={float <}]{\sorted}{\datatable}%
\pgfplotstablegetelem{0}{rownumber}\of{\sorted}%
\pgfmathtruncatemacro#3{\pgfplotsretval}
\pgfplotstableclear{\datatable}
}
\pgfplotstableset{
highlight col min/.code 2 args={
\findmin{#1}{#2}{\minval}
\edef\setstyles{\noexpand\pgfplotstableset{
every row \minval\noexpand\space column #2/.style={
postproc cell content/.append style={
/pgfplots/table/@cell content/.add={$\noexpand\bf}{$}
},
}
}
}\setstyles
}
}
\pgfplotstableread{
a b
1 3.3
2 2.2
3 1.1
4 -101.2
5 -100.3
6 -992.3
7 0.9
8 0.3
9 0.4
}\data
\begin{document}
\begin{table}
\pgfplotstabletypeset[
columns={a,b},
highlight col min ={\data}{b},
every head row/.style={before row=\toprule,after row=\midrule},
every last row/.style={after row=\bottomrule},
every nth row={3}{before row=\midrule}
]{\data}
\end{table} % I want 1.1, -992.3, and 0.3 bolded - not just -992.3
\end{document}
I found the syntax hard to understand and I want to ask the experienced people here. Reading the pgfplotstable docs didn't help me get closer to a solution.
