3

I'm using pgfplotstable to create tables from .csv-files. I would like being able to change the font of specific numerical cells. In particular, I would like to change the font of these cells to look, as if they were written by hand.

Here is a MWE:

\documentclass{article}

\usepackage{multirow}
\usepackage{booktabs}
\usepackage{pgfplotstable}

%Make rows higher:
\setlength\extrarowheight{1.4pt}

%GLOBAL FORMATING:
\pgfkeys{/pgf/number format/.cd,
                use comma,
                1000 sep={}}

\usepackage{lipsum}
\usepackage{filecontents}

\begin{filecontents}{data.csv}
Name,1,2
A,10.23,3.23
B,11.23,4.23
C,12.23,5.23
D,13.23,6.23
E,14.23,7.23
F,15.23,8.23
\end{filecontents}

\begin{document}

\lipsum[1]

\begin{table}[!htb]
\centering
\caption{Some text describing the table}

\pgfplotstabletypeset[col sep=comma,
    columns={Name, 1, 2},% <---these columns will appear in the table
%------------------TYPESETTING COLUMNS:-------------------------------
     columns/Name/.style={% <---style column "Name"
      string type,%
      column type/.add={}{|},%
    },
    %
    columns/1/.style={% <---style column "1"
      column name=I,
      precision=1,column type/.add={}{|},%
    },
    %
    columns/2/.style={% <---style column "2"
      column name=II,
      precision=1, column type/.add={}{},%
    },
    %
%------------------TYPESETTING ROWS-------------------------------
    every head row/.style={before row=\toprule, after row=\midrule},%
    every last row/.style={after row=\bottomrule}%
    ]%
{data.csv}
\end{table}

\lipsum[2]



\end{document}

Here is what it looks like:

The picture only shows a normal table. I would like to change the font of a specific cell.

How can I change the font of the cell containing 4,2 for instance? And what would be an appropriate font?

Help much appreciated!

Wamseln
  • 798

1 Answers1

4

I've used any font from the CTAN catalouge and I always find this type of font switches kind of annoying and clunky. You can instead use whatever font you wish from your system using fontspec and switching to either Lua- or Xe-Latex compilation.

\documentclass{article}
\usepackage{multirow,booktabs,pgfplotstable,lipsum}

\usepackage[T1]{fontenc}
\usepackage{emerald}

\setlength\extrarowheight{1.4pt}
\pgfkeys{/pgf/number format/.cd,use comma,1000 sep={}}

\begin{document}
\lipsum[1]

\begin{table}[!htb]
\centering
\caption{Some text describing the table}

\pgfplotstabletypeset[col sep=comma,
    columns={Name, 1, 2},% <---these columns will appear in the table
%------------------TYPESETTING COLUMNS:-------------------------------
     columns/Name/.style={% <---style column "Name"
      string type,%
      column type/.add={}{|},%
    },
    %
    columns/1/.style={% <---style column "1"
      column name=I,
      precision=1,column type/.add={}{|},%
    },
    %
    columns/2/.style={% <---style column "2"
      column name=II,
      precision=1, column type/.add={}{},
      postproc cell content/.append code={%
        \ifnum\pgfplotstablerow=3%
            \pgfkeyssetvalue{/pgfplots/table/@cell content}{\ECFJD ##1}%
        \fi%
        }
    },
    %
%------------------TYPESETTING ROWS-------------------------------
    every head row/.style={before row=\toprule, after row=\midrule},%
    every last row/.style={after row=\bottomrule}%
    ]%
{
Name,1,2
A,10.23,3.23
B,11.23,4.23
C,12.23,5.23
D,13.23,6.23
E,14.23,7.23
F,15.23,8.23
}
\end{table}

\lipsum[2]
\end{document}

enter image description here

percusse
  • 157,807
  • There is still one problem though: With this approach the formatting of the cell changes. How could I use the answer to this question (http://tex.stackexchange.com/questions/253897/pgfplotstable-postproc-cell-content-resets-style-of-cell) to change the font of the cell and preserve its formatting? – Wamseln Jul 06 '15 at 13:03