2

How to change the font size of a particular column using pgfplotstable? I only found how to change the font size of the whole table with e.g. font=\small.

edit: the column header may be changed as well, although it would be nice to have this as an option.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
Somebody
  • 1,217
  • Do you want to change the font size of the column header as well? – Jake Aug 15 '13 at 06:24
  • 2
    Please provide a minimum (possbly non-) working example of what you've tried to accomplish so far. There are lots of ways of creating tables with pgfplotstable -- getting an idea from you as to how you'd like to organize the table's structure would be very helpful. – Mico Aug 17 '13 at 13:33
  • Not linked to the question, but please consider picking a more 'memorable' user name than user... :-) – Joseph Wright Aug 17 '13 at 13:47

2 Answers2

6

The pgfplotstable package allows you to use the facilities of the array package (provided it is loaded) and allows you to either use custom column types (as explained in the array documentation), or to add the the existing specification of a column.

The array package allows you to specify code at the beginning and end of each cell in a column. See this question for details on how that works.

pgfplotstable provides hooks into this using the column type key. Here's example. I've shown how to make each column have a different size, and also how to make the column header have a different size from the rest of the column.

\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{array}
\begin{filecontents}{\jobname.csv}
A, B
1,100
2,200
3,300
4,400
\end{filecontents}
\begin{document}
\pgfplotstabletypeset
 [col sep=comma,
      columns/A/.style=
         {column type/.add={>{\Large}}{}},
      columns/B/.style=
         {column type/.add={>{\small}}{},
          column name={\Huge B}}
 ]{\jobname.csv}
\end{document}

output of code

Alan Munn
  • 218,180
3

Section 3.4 of the pgfplotstable manual gives examples of formatting cells via post processing.

Sample output

\documentclass{article}

\usepackage{pgfplotstable}
\pgfplotsset{compat=1.8}

\begin{document}

\pgfplotstabletypeset[
columns/error1/.style={column name=$E1$},
columns/error2/.style={column name=$E2$,
  postproc cell content/.append style={
  /pgfplots/table/@cell content/.add={\LARGE$\it}{$}}
  },
columns/dof/.style={string type,column name=\textsc{Dof},
  postproc cell content/.append style={
  /pgfplots/table/@cell content/.add={\bfseries\Huge\strut}{}}
}] {ex.dat}

\end{document}

with ex.dat being

error1 error2 dof
0.2    0.1    b
0.1    0.07   c

The /pgfplots/tabel/@cell content/.add inserts its first argument before the cell cotents and its second argument after. Column 2 is an example of number styling and column 3 is for text.

Andrew Swann
  • 95,762
  • Is the only difference between this and my solution the use of array? This seems a bit low level, but is effectively the same solution. – Alan Munn Aug 17 '13 at 20:28
  • 1
    The methods are certainly similar. The difference is whether the specification is at the cell level or in the table's column formatting specification. As the manual shows, the above method allows to do more sophisticated things depending on the particular cell's contents, e.g. negative numbers in red. – Andrew Swann Aug 18 '13 at 09:08