如何使用 pgfplotstable 更改特定(数字)单元格的字体?

如何使用 pgfplotstable 更改特定(数字)单元格的字体?

我正在使用 pgfplotstable 从 .csv 文件创建表格。我希望能够更改特定数字单元格的字体。具体来说,我希望更改这些单元格的字体,使其看起来就像手写的一样。

以下是 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}

它看起来是这样的:

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

我如何更改包含4,2例如的单元格的字体?哪种字体合适?

非常感谢帮助!

答案1

我用过CTAN 目录中的任何字体我总是觉得这种字体切换有点烦人且笨重。你可以使用系统中你想要的任何字体fontspec,然后切换到 Lua 或 Xe-Latex 编译。

\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

相关内容