# Automatic way to match matrix heights

I have a simple matrix equation, but one of the matrices has subscripts and superscripts on both lines:

\documentclass{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}

$\begin{vmatrix} x_2 \\x_2' \end{vmatrix} = \begin{vmatrix} \frac{d_2}{f_1}&-\frac{d_1d_2}{f_1}\\-\frac{1}{f_1}&1-\frac{d_1}{f_1} \end{vmatrix} \begin{vmatrix} x_1\\x_1' \end{vmatrix}$

\end{document}


so the matrices are slightly different heights (top line in example below - red rule added to demonstrate). It wouldn't look so bad if they were very different. I can use \vphantom\frac... to enlarge the two smaller matrices:

$\begin{vmatrix} x_2 \vphantom{\frac{d_2}{f_1}}\\x_2'\vphantom{\frac{d_2}{f_1}} \end{vmatrix} = \begin{vmatrix} \frac{d_2}{f_1}&-\frac{d_1d_2}{f_1}\\-\frac{1}{f_1}&1-\frac{d_1}{f_1} \end{vmatrix} \begin{vmatrix} x_1\vphantom{\frac{d_2}{f_1}}\\x_1'\vphantom{\frac{d_2}{f_1}} \end{vmatrix}$


(second line in example image) but is there a way to make all the matrix heights in an equation match - either within a particular equation, or something I can do globally? • You can use a strut, an invisible character which is as large at the largest entry. You place the strut in every row of every matrix. First you need to find the maximum height (see \settoheight) then create your strut using \rule. Oct 3, 2013 at 12:53
• No unless you use some insane input syntax, how should the construction before the = know about the size of the matrix. So you need some strange construction to do all the measuring and stuff behind the scenes. And then you have the problems of applying this to say typesetting this in align. Oct 3, 2013 at 12:53
• @JohnKormylo He’s basically doing this with the \vphantom command, which measures the height and depth of its argument and typesets a rule with that height and depth. Oct 3, 2013 at 13:00
• Yeah, I was trying to delete or replace my comment when the time limit ran out. Oct 3, 2013 at 13:02

\renewcommand\arraystretch{1.2} 