填充矩阵中的元素

填充矩阵中的元素

是否可以调整矩阵中元素周围的填充,如下图所示。

狭窄矩阵示例

代码如下所示

\documentclass{scrartcl}
\usepackage{amsmath}

\begin{document}

... in general we have

\begin{equation}
    \begin{bmatrix}
        \frac{\partial f_1}{\partial x_1} & \cdots &
        \frac{\partial f_1}{\partial x_n} \\
        \vdots & \ddots & \vdots \\
        \frac{\partial f_m}{\partial x_1} & \cdots &
        \frac{\partial f_m}{\partial x_n}
    \end{bmatrix}
\end{equation}

and for the particular case of $m=n=2$ 

\begin{equation}
    \begin{bmatrix}
        \frac{\partial f_1}{\partial x_1} & \frac{\partial f_1}{\partial x_2} \\
        \frac{\partial f_2}{\partial x_1} & \frac{\partial f_2}{\partial x_2}
    \end{bmatrix}
\end{equation}


Is it possible to insert some space around the elements in (2)? The matrix looks a bit cramped.

\end{document}

答案1

下面是带有 的代码cellspace。无关:我建议使用diffcoeff 包来简化偏导数的输入,并使用\medmath来自的命令nccmath在矩阵中获取中等大小的分数(默认值为\tfrac):

\documentclass{article}
\usepackage{amsmath, nccmath}
\usepackage{diffcoeff}
\usepackage[math]{cellspace}
\setlength{\cellspacetoplimit}{2pt}
\setlength{\cellspacebottomlimit}{2pt}

\begin{document}

\[ J = \begin{pmatrix}
        \medmath{\diffp{f_1}{x_1}} & \medmath{\diffp{f_1}{x_2}} \\
         \medmath{\diffp{f_2}{x_1}} & \medmath{\diffp{f_2}{x_2}}
    \end{pmatrix}
\]

 \end{document} 

在此处输入图片描述

相关内容