如何在单元格中填充并将文本颜色放入字符串单元格 pgfplotstable

如何在单元格中填充并将文本颜色放入字符串单元格 pgfplotstable

代码:

\usepackage{pgf,tikz}
\usepackage{pgfplots}
\usetikzlibrary{arrows}
\usepackage{pgfplotstable,booktabs,array,colortbl,multirow}

\newcolumntype{C}{>{\centering\arraybackslash}m{5cm}}
\pgfplotsset{compat=1.5}
\begin{table}[!hbt]
\begin{center}
\pgfplotstabletypeset[
    row sep=\\,
    col sep=&,
    trim cells,
    columns={f(x),f'(x)},
    columns/f(x)/.style={string type, column type={|C|}},
    columns/f'(x)/.style={string type, column type={C|}},
    every nth row={1}{before row=\hline},
    every head row/.style={before row=\hline, after row=\hline},
    every last row/.style={after row=\hline}
]
{
f(x) & f'(x) \\
{$k$} & $0$\\
{$x$} & $1$\\
{$x^{n}$} & $n\cdot x^{n-1}$\\
{$u^{n}$} & $n\cdot x^{n-1}\cdot u^{'}$\\
{$\sqrt{x}$} & $\dfrac{1}{2\sqrt{x}}$\\
{$\sqrt[n]{u}$} & $\cfrac{u^{'}}{n\sqrt[n-1]{u^{n-1}}}$\\
{$\ln u$} & $\dfrac{u^{'}}{u}$\\
{$\log_{a}u$} & $\dfrac{u^{'}}{u}\cdot\dfrac{1}{\ln a}$\\
{$a^{u}$} & $a^{u}\cdot u^{'}\cdot\ln a$\\
{$e^{x}$} & $e^{x}$\\
{$e^{u}$} & $e^{x}\cdot u^{'}$\\
{$\sin u$} & $\cos u\cdot u^{'}$\\
{$\cos u$} & $-\sin u\cdot u^{'}$\\
{$\tan u$} & $\dfrac{u^{'}}{\cos^{2}u}$\\
{$\arcsin u$} & $\dfrac{u^{'}}{\sqrt{1-u^{2}}}$\\
{$\arccos u$} & $-\dfrac{u^{'}}{\sqrt{1-u^{2}}}$\\
{$\arctan u$} & $\dfrac{u^{'}}{1+u^{2}}$\\
{$\sinh u$} & $u^{'}\cdot\cosh u$\\
{$\cosh u$} & $u^{'}\cdot\sinh u$\\
{$\tanh u$} & $-u^{'}\cdot cosech^{2}u$\\
{$cosech\: u$} & $-u^{'}\cdot cosech\: u\cdot\coth u$\\
{$sech\: u$} & $-u^{'}\cdot sech u\cdot\tanh u$\\
{$coth\: u$} & $-u^{'}\cdot cosech^{2} u$\\
}
\caption{Tabla De Derivadas}
\end{center}
\end{table}

我想将 f(x) 和 f'(x) 中的文本变为蓝色。当我在单元格中使用分数表达式时,文本会触及单元格的底线和顶线,我怎样才能增加这些单元格的高度?

谢谢。

答案1

您可以通过自动将内容置于数学模式并删除标题行来简化一些事情,因为第一行中有数学

\documentclass{article}
\usepackage{pgfplotstable,booktabs,colortbl,multirow,amsmath}
\newcolumntype{C}{>{\centering\arraybackslash\raisebox{-4mm}{\rule{0pt}{1cm}}}m{5cm}}
\pgfplotsset{compat=1.5}

\begin{document}
\begin{table}
\centering
\pgfplotstabletypeset[
    row sep=\\,
    col sep=&,
    column type=,
    string type,header=false,
    begin table=\begin{tabular}{|C|C|},
    every head row/.style={after row=\hline,output empty row},
    every nth row={1}{before row=\hline},
    every row/.append style={before row=\hline},
    every last row/.style={after row=\hline},
    postproc cell content/.style={/pgfplots/table/@cell content/.add={$\displaystyle}{$}},
]
{
\color{blue}f(x)    & \color{blue}f'(x)                    \\
k                   & 0                                    \\
x                   & 1                                    \\
x^{n}               & n\cdot x^{n-1}                       \\
u^{n}               & n\cdot x^{n-1}\cdot u'               \\
\sqrt{x}            & \dfrac{1}{2\sqrt{x}}                 \\
\sqrt[n]{u}         & \cfrac{u'}{n\sqrt[n-1]{u^{n-1}}}     \\
\ln u               & \dfrac{u'}{u}                        \\
\log_{a}u           & \dfrac{u'}{u}\cdot\dfrac{1}{\ln a}   \\
a^{u}               & a^{u}\cdot u'\cdot\ln a              \\
e^{x}               & e^{x}                                
}
\caption{Tabla De Derivadas}
%\end{center}
\end{table}
\end{document}

在此处输入图片描述

相关内容