Aligned vector, matrix, vector, multiplication
I would use bmatrix
environments instead of generic array
environments, and I would not raise the row vector above the baseline.
Using \overline
and \underline
may be an acquired taste. To my taste, though, the lines produced by these macros look really heavy, even domineering. Using \bar{...}
and \underaccent{\bar}{...}
(\underaccent
is courtesy of the accents
package) provides a lighter-looking solution; see the second row belo2. In that solution, I insert a couple of (typographic) struts (called \bstrut
in the code) to fine-tune the positions of the numerator terms \partial{\bar{y}}
.
\documentclass{article}
\usepackage{mathtools,accents}
% Create a typographic (bottom) strut:
\newcommand\bstrut{\vphantom{\underaccent{\bar}{y}}}
\begin{document}
\begin{align*}
\frac{dz}{dt}
&= \begin{bmatrix}
1 & -1
\end{bmatrix}
\begin{bmatrix}
\frac{\partial\underline{y}}{\partial\underline{x}} &
\frac{\partial\overline{y}}{\partial\underline{x}}\\[1ex]
\frac{\partial\underline{y}}{\partial\overline{x}} &
\frac{\partial\overline{y}}{\partial\overline{x}}
\end{bmatrix}
\begin{bmatrix*}[r]
1 \\ -1
\end{bmatrix*} \\
&= \begin{bmatrix}
1 & -1
\end{bmatrix}
\begin{bmatrix}
\frac{\partial\underaccent{\bar}{y}}{\partial\underaccent{\bar}{x}} &
\frac{\partial\bar{y}\bstrut}{\partial\underaccent{\bar}{x}}\\[1.25ex]
\frac{\partial\underaccent{\bar}{y}}{\partial\bar{x}} &
\frac{\partial\bar{y}\bstrut}{\partial\bar{x}}
\end{bmatrix}
\begin{bmatrix*}[r]
1 \\ -1
\end{bmatrix*}
\end{align*}
\end{document}
I propose to use a single blockarray
, the \medmath
command from nccmath
to have medium-size fraction inside arrays, and the diffcoeff
package, for a simple syntax for partial derivatives. I also replaced \overline
with \widebar
, which is a real math accent from `mathabx (without loading the package).
\documentclass{article}
\usepackage{mathtools}
\usepackage{blkarray, bigstrut}
\usepackage{diffcoeff}
\usepackage{nccmath}
\newcommand{\mdiffp}[2]{\medmath{\diffp{#1}{#2}}}
\usepackage[math]{cellspace}
\setlength{\cellspacetoplimit}{2pt}
\setlength{\cellspacebottomlimit}{3pt}
\DeclareFontFamily{U}{mathx}{\hyphenchar\font45}
\DeclareFontShape{U}{mathx}{m}{n}{
<-6> mathx5 <6-7> mathx6 <7-8> mathx7
<8-9> mathx8 <9-10> mathx9
<10-12> mathx10 <12-> mathx12
}{}
\DeclareSymbolFont{mathx}{U}{mathx}{m}{n}
\DeclareFontSubstitution{U}{mathx}{m}{n}
\DeclareMathAccent{\widebar}{0}{mathx}{"73}
\begin{document}
\[ \setlength{\bigstrutjot}{0.75em}\diff{z}{r} = \begin{blockarray}
{@{}cc@{\hskip 0.65em}[cc][r]}
\boldsymbol{[}\, 1 & -1\, \boldsymbol{]} &\bigstrut\mdiffp{\underline{y}}{ \underline{x}} &\mdiffp{\widebar{y}}{ \underline{x}} & 1\\%[2ex]
& & \bigstrut\mdiffp{\underline{y}}{\widebar{x}} & \mdiffp{\widebar y}{ \widebar x } & -1
\end{blockarray}\]%
\end{document}
Getting alignments with so inhomogeneous objects requires a bit of manual adjusting.
I raised the first row vector “by eye”; it would be possible to compute the amount of raising exactly, but I did it just to show that it's really awful and unhelpful for the reader. Why the top and not the bottom? There's no reason for choosing either, so the right place is at the center.
More importantly, I added some shorthands that help both in typing and in reading code.
Some “phantoms” make the objects align nicely.
\documentclass{article}
\usepackage{amsmath,bm}
\newenvironment{rowvector}
{\bm{[}\begin{matrix}}
{\end{matrix}\bm{]}}
\newcommand{\pder}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\ol}{\overline}
\newcommand{\ul}{\underline}
\begin{document}
\[
\frac{dz}{dt} =
\raisebox{3ex}{$\begin{rowvector} 1 & -1 \end{rowvector}$}
\begin{bmatrix}
\pder{\ul{y}}{\ul{x}} & \pder{\ol{y}\vphantom{\ul{y}}}{\ul{x}} \\[0.5em]
\pder{\ul{y}}{\ol{x}} & \pder{\ol{y}\vphantom{\ul{y}}}{\ol{x}}
\end{bmatrix}
\begin{bmatrix}
1 \vphantom{\pder{\ul{y}}{\ul{x}}} \\[0.5em]
-1 \vphantom{\pder{\ul{y}}{\ul{x}}}
\end{bmatrix}
\]
\[
\frac{dz}{dt} =
\begin{rowvector} 1 & -1 \end{rowvector}
\begin{bmatrix}
\pder{\ul{y}}{\ul{x}} & \pder{\ol{y}\vphantom{\ul{y}}}{\ul{x}} \\[0.5em]
\pder{\ul{y}}{\ol{x}} & \pder{\ol{y}\vphantom{\ul{y}}}{\ol{x}}
\end{bmatrix}
\begin{bmatrix}
1 \vphantom{\pder{\ul{y}}{\ul{x}}} \\[0.5em]
-1 \vphantom{\pder{\ul{y}}{\ul{x}}}
\end{bmatrix}
\]
\end{document}