3

I am trying to surround all elements in a specific table row with square brackets, using postproc cell content in pgfplotstable.

As shown in the MWE, it works well for processing a column, but not for a row:

\documentclass{article}
\usepackage{pgfplotstable}
\begin{document}

\pgfplotstabletypeset[
    string type,
    every first row/.append style={postproc cell content/.append style={/pgfplots/table/@cell content/.add={[}{]}}},
    columns/B/.append style={postproc cell content/.append style={/pgfplots/table/@cell content/.add={[}{]}}},
]{
    A B C
    m s kg
    1 2 3
    4 5 6
    7 8 9
}
\end{document}

Result

I had expected to see all elements in the second row (every first row) as well as in column B surrounded by square brackets.

Does postproc cell content not work on a per row basis?

1 Answer 1

3

A question which reveals an unclear definition in pgfplotstable. A look into its source code confirms that postproc cell content is only applicable in the context where column styles are evaluated.

This is either a missing feature or at least something which needs to be clarified in the manual. Probably the first.

In the meantime, you can use every row <index> column <name> which supports postproc cell content:

\documentclass{standalone}
\usepackage{pgfplotstable}
\begin{document}

\pgfplotstabletypeset[
    string type,
    brackets/.style={
        postproc cell content/.append style={/pgfplots/table/@cell content/.add={\relax[}{]}},
    },
    every row 0 column A/.append style={brackets},
    %every row 0 column B/.append style={brackets},
    every row 0 column C/.append style={brackets},
    columns/B/.append style={brackets},
]{
    A B C
    m s kg
    1 2 3
    4 5 6
    7 8 9
}
\end{document}

enter image description here

I took the freedom to define a separate style for your brackets.

Note the \relax: it turns out that pgfplotstable works well without it, but tabular does not: it assumes that the brackets are associated with the preceding \\. To see this, add debug to your options and look into the log file.

Note that there is also every row <index> column no <index>.

You must log in to answer this question.

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