1

I am using pgfplotstabletypset to read in a table -- I want all cells in the first column with the expression Factor in them to be aligned to the left and bolded, and I want all cells without that expression to be aligned to the left and not bolded. Not sure how to implement these rules.

3
  • So you dont want the entire column to be bolded?
    – azetina
    Commented Dec 8, 2012 at 6:02
  • Right, I want a cell to be bolded and aligned left in the first column if it has the word 'Factor' in it. Otherwise, I want it to be non-bold and left aligned.
    – mike
    Commented Dec 8, 2012 at 6:03
  • See my answer for a possible solution.
    – azetina
    Commented Dec 8, 2012 at 6:39

1 Answer 1

3

Say you have your data file in .csv format created when compiling the following:

\documentclass{minimal}
\begin{filecontents*}{scientists.csv}
name,surname,age
Albert,Einstein,133
Factor and,Curie,145 % add the word and just to illustrate
Thomas,Edison,165
\end{filecontents*}

Once the scientists.csv has been created then you can compile the following which will do what you want:

\documentclass{article}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.7}
\begin{document}
\pgfplotstabletypeset[%
    col sep=comma,%
    string type,%
    columns/name/.style={column name=Name, column type={|l}, string replace*={Factor}{\bfseries Factor}},
    columns/surname/.style={column name=Surname, column type={|l}},%
    columns/age/.style={column name=Age, column type={|c|}},%
    every head row/.style={before row=\hline,after row=\hline},%
    every last row/.style={after row=\hline},%
    ]{scientists.csv}
\end{document}

The tricky part is to use string replace*={Factor}{\bfseries Factor}. Thus we get:

enter image description here

1
  • Thanks very much -- most of what I need -- is it possible to have the alignment be different if the word 'Factor' appears? Is it possible to have an if/else statement for the column type = ?? Thanks,
    – mike
    Commented Dec 9, 2012 at 0:25

You must log in to answer this question.

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