12

Considering this MWE, I am looking to obtain bold style on a row. The highlight's style works on columns but not on row.

\documentclass{standalone}
\usepackage{pgfplotstable}

\begin{document}
\pgfplotstableset{highlight/.append style={
    postproc cell content/.append code={
            \pgfkeysalso{@cell content=\textbf{##1}}%
    }
}}
\pgfplotstabletypeset[
   every first column/.style={highlight,/pgf/number format/sci},
   every last row/.style={highlight,/pgf/number format/sci}, %does not work
    col sep=&,row sep=\\]{
  colA & colB & colC \\
  11   & 12   & 13   \\
  21   & 22   & 23   \\
}
\end{document}

Do you any idea ? This seems that postproc cell content does not work on rows.

EDIT

Another problem is that the \pgfkeysalso remove the sci formatting....

\documentclass{standalone}
\usepackage{pgfplotstable}

\begin{document}
\pgfplotstableset{hhb/.append style={
    postproc cell content/.append code={
            \pgfkeysalso{@cell content=\textbf{##1}}%
    }
}}
\pgfplotstabletypeset[
 every first column/.style={highlight,/pgf/number format/sci},
 % every last row/.append style={highlight},
 %every first column/.style={sci,postproc cell content/.append style=    {/pgfplots/table/@cell content/.add={\bf}{coucou}}},
  col sep=&,row sep=\\]{
 colA & colB & colC \\
 11   & 12   & 13   \\
 3E+4   & 22   & 23   \\
}
\end{document}

EDIT 2:

In order to avoid the previous problem, the syntax must be:

\pgfplotstableset{hhc/.style={
postproc cell content/.append style={
            /pgfplots/table/@cell content/.add={$\bf}{$},
        }
        }}

But this works only for the columns and not for rows.

EDIT 3:

Solution to make ith row in bold:

\pgfplotstableset{
    highlightrow/.style={
        postproc cell content/.append code={
           \count0=\pgfplotstablerow
            \advance\count0 by1
            \ifnum\count0=#1
            \pgfkeysalso{@cell content/.add={$\bf}{$}}
               %\pgfkeysalso{@cell content=\textbf{##1}}%
            \fi
        },
    },
}

Example of use:

\pgfplotstabletypeset[ highlightrow={2},
    col sep=&,row sep=\\]{
  colA & colB & colC \\
  11   & 12   & 13   \\
  3E+4   & 22   & 23   \\
}
2
  • This question is so underrated. Thanks for that highlight solution EDIT 3! I changed {$\bf}{$} to {\bfseries}{} so that I can get use formatting commands within the rows that override the global settings (see tex.stackexchange.com/questions/236210/…). Apr 7, 2015 at 6:59
  • I tried highlightrow=0 to make the header bold, but it doesn't work. Any idea about the reason for this?
    – summer
    Dec 24, 2015 at 10:07

1 Answer 1

15

You are right, the postproc options apply only to column--specific options.

In order to restrict their application to specific rows, you have to make them dependent on the row index \pgfplotstablerow:

\documentclass{standalone}
\usepackage{pgfplotstable}

\begin{document}
\pgfplotstableset{
    highlight/.append style={
        postproc cell content/.append code={
                \pgfkeysalso{@cell content=\textbf{##1}}%
        },
    },
    highlight last row/.style={
        postproc cell content/.append code={
            \count0=\pgfplotstablerow
            \advance\count0 by1
            \ifnum\count0=\pgfplotstablerows
                \pgfkeysalso{@cell content=\textbf{##1}}%
            \fi
        },
    },
}
\pgfplotstabletypeset[
   every first column/.style={highlight,/pgf/number format/sci},
   highlight last row,
   every last row/.style={/pgf/number format/sci},
    col sep=&,row sep=\\]{
  colA & colB & colC \\
  11   & 12   & 13   \\
  21   & 22   & 23   \\
}
\end{document}

enter image description here

The manual was quite unclear on this particular aspect; I have improved the manual and introduced a check which detects such issues.

1
  • Thank you for your solution, I have proposed a new style based on your solution for making bold a specific row (EDIT 3 of my question).
    – Guuk
    Aug 31, 2013 at 12:17

You must log in to answer this question.

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