# Vertical spacing in matrix environment : how can I have the same?

Here's my problem : I'm trying to write a Jacobian matrix as a product of two other's, but the result is wrong because they don't have the same height. Here's my code :

\documentclass[11pt]{book}
\usepackage{amsmath}
\begin{document}

\begin{align*}
Jac(f \circ \varphi)_{x_0} =& Jac(f)_{\varphi(x_0)} Jac(\varphi)_{x_0} \\
=& \begin{pmatrix}
\frac{\partial f}{\partial x}(r \cos(\theta), r \sin(\theta)) \\
\frac{\partial f}{\partial y}(r \cos(\theta), r \sin(\theta))
\end{pmatrix} \begin{pmatrix}
\cos(\theta) & -r \sin(\theta) \\
\sin(\theta) & r \cos(\theta)
\end{pmatrix}
\end{align*}
\end{document}


I'd like not to use tricks as /em. Would you have a solution ? Thanks !

-

I'd not insist in the matrices to have the same height; rather I'd use \dfrac for the inner partial derivatives and space out a bit the rows; see the second alignment for having the same height.

\documentclass[11pt]{book}
\usepackage{amsmath}
\DeclareMathOperator{\Jac}{Jac}

\begin{document}

\begin{align*}
\Jac(f \circ \varphi)_{x_0}
&= \Jac(f)_{\varphi(x_0)} \Jac(\varphi)_{x_0} \\
&= \begin{pmatrix}
\dfrac{\partial f}{\partial x}(r \cos(\theta), r \sin(\theta)) \\[3ex]
\dfrac{\partial f}{\partial y}(r \cos(\theta), r \sin(\theta))
\end{pmatrix}
\begin{pmatrix}
\cos(\theta) & -r \sin(\theta) \\[2ex]
\sin(\theta) & r \cos(\theta)
\end{pmatrix}
\end{align*}
\begin{align*}
\Jac(f \circ \varphi)_{x_0}
&= \Jac(f)_{\varphi(x_0)} \Jac(\varphi)_{x_0} \\
&= \begin{pmatrix}
\frac{\partial f}{\partial x}(r \cos(\theta), r \sin(\theta)) \\[1ex]
\frac{\partial f}{\partial y}(r \cos(\theta), r \sin(\theta))
\end{pmatrix}
\begin{pmatrix}
\cos(\theta) & -r \sin(\theta) \\[1ex]
\sin(\theta) & r \cos(\theta)
\end{pmatrix}
\end{align*}
\end{document}


Note the usage of a math operator and the correct &= instead of =&.

-

Using \mfrac (medium-sized fraction) from the nccmath package gives a more sensible size for the matrix. I think the worse (aesthetically speaking) would be to have lines almost aligned, so you'd have to manually add some space between the rows of the second matrix, and if you change the font, or even the font size, you may have to tweak everything again.

There would be an automatic way of exactly aligning the matrices, using the blkarray package and writing only 1 matrix with delimiters inside. However it has some flaws: it doesn't work well with align, so that, for instance the alignment point (=) has to be written before the ampersand. Anyhow, the following code shows both methods. I also used the cellspace package to give some ease to the lines in matrices (doesn't work with blkarray):

    \documentclass[11pt, leqno]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\DeclareMathOperator{\Jac}{Jac}
\usepackage{blkarray}
\usepackage{nccmath}
\usepackage[math]{cellspace}
\cellspacetoplimit = 3pt
\cellspacebottomlimit = 3pt

\begin{document}

\begin{align*}
\Jac(f \circ \varphi)_{x_0} =&\Jac(f)_{\varphi(x_0)} \Jac(\varphi)_{x_0} \\
\mfrac{\partial f}{\partial x}(r \cos(\theta), r \sin(\theta)) \\
\mfrac{\partial f}{\partial y}(r \cos(\theta), r \sin(\theta))
\end{pmatrix} \begin{pmatrix}
\cos(\theta) & -r \sin(\theta) \\[6pt]
\sin(\theta) & r \cos(\theta)
\end{pmatrix}
\\%
\tag*{\small with blkarray:}       = &{\ } \begin{blockarray}[t]{(c)!{\ }(cc)}
\mfrac{\partial f}{\partial x}(r \cos(\theta), r \sin(\theta)) &  \cos(\theta) & -r \sin(\theta)\\[8pt]
\mfrac{\partial f}{\partial y}(r \cos(\theta), r \sin(\theta)) & \sin(\theta) & r \cos(\theta)
\end{blockarray}
\end{align*}

\end{document}


-