Preenchimento em torno de elementos em uma matriz

Preenchimento em torno de elementos em uma matriz

É possível ajustar o preenchimento em torno dos elementos de uma matriz, conforme indicado na figura abaixo.

Exemplo de matriz restrita

O código é mostrado abaixo

\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}

Responder1

Aqui está um código com cellspace. Não relacionado: sugiro usar o diffcoeff pacote para simplificar a digitação de derivadas parciais, e o \medmathcomando from nccmathpara ter frações de tamanho médio em matrizes (o padrão é \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} 

insira a descrição da imagem aqui

informação relacionada