3

What's the easiest way to control the text size of all non-header cells of a column in a table created by pgfplotstable?

\documentclass{article}
\usepackage{pgfplotstable}

\begin{document}
\pgfplotstabletypeset[col sep=comma, header=has colnames]{
test1,test2
1,2
3,4
}
\end{document}

So, for example, in this table, I want to change the size of 2 and 4.

I tried playing with .style={font=...}, but got nowhere. Also, I found columns/test2/.style={postproc cell content/.style={@cell content/.add={\scriptsize}{}}} here, but I can't believe that is the easiest way.

  • Enclose your table code with {\everymath{\scriptstyle} ..... } which would make all the math scriptstyle by default. inside those braces. And by default pgfplotstable typesets columns with $...$ around the content. – percusse Aug 9 '13 at 9:43
  • Unluckily, this doesn't work for text cells, and doesn't let me select only some columns, right? – fefrei Aug 9 '13 at 9:45
4

OK. Here is a repeatable setting way. Pgfkeys offers an iterating execution of keys via /.list handler. In english, it will execute the same style for every element in the list. Example, I've made added \scriptsize to the cells and made them string type.

\documentclass{article}
\usepackage{pgfplotstable}

\pgfplotstableset{
    my iterating settings/.style={%
        /pgfplots/table/columns/#1/.style={
            string type,
            postproc cell content/.style={
                 @cell content/.add={\scriptsize}{}
            }
        }
    }
}

\begin{document}
\pgfplotstabletypeset[my iterating settings/.list={test1,test2,test3,test4}]{
test1 test2 test3 test4
1     2     6     8
3     4     7     9
c     u     b     e
c     a     k     e
}
\end{document}

enter image description here

Too tired to enter the column names, want an easier solution? We still love you. You can use the column number index for ease of access since pgfplotstable supports display columns/<col no> syntax. Example, I want some columns bold and \footnotesize (I don't know why).

Notice that I have shifted the string type out to the general setting to apply to all columns because our iterating list doesn't touch each column but all has text in them. And column numbers start from zero.

\documentclass[landscape]{article}
\usepackage{pgfplotstable}

\pgfplotstableset{
    my num iterating settings/.style={%
        /pgfplots/table/display columns/#1/.style={
            postproc cell content/.style={
                 @cell content/.add={\footnotesize\bfseries}{}
            }
        }
    }
}

\begin{document}
\hspace{-5cm}
\pgfplotstabletypeset[string type,
    my num iterating settings/.list={0,1,...,4,8,10,...,15}
    ]{
test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 test15 test16
1     2     6     8     1     2     6     8     1     2     6     8        1     2     6     8
3     4     7     9     3     4     7     9     3     4     7     9        3     4     7     9
c     u     b     e     c     u     b     e     c     u     b     e        c     u     b     e
c     a     k     e     c     a     k     e     c     a     k     e        c     a     k     e
}
\end{document}

enter image description here

I might have copy-pasted a little too much...

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.