11

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   \\
}
  • 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/…). – Jonathan Komar Apr 7 '15 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 '15 at 10:07
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.

  • 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 '13 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.