How do I adjust \underbrace spacing?

I have an equation like this

\documentclass{article}
\usepackage{IEEEtrantools}
\usepackage{amsmath}
\begin{document}
\begin{IEEEeqnarray*}{rClCl}
\left(
\begin{array}{c}
f\frac{X}{Z} \\ f\frac{Y}{Z}\\ 1
\end{array}
\right) & \sim &
\left(
\begin{array}{c}
fX \\ fY \\ Z
\end{array}
\right) & = & \underbrace{\left(
\begin{array}{cccc}
f & 0 & 0 & 0 \\
0 & f & 0 & 0 \\
0 & 0 & 1 & 0
\end{array}
\right)}_{\text{Projection Matrix of $C$}} \left(\begin{array}{c} X \\ Y \\ Z \\ 1 \end{array}\right)
\end{IEEEeqnarray*}

\end{document}


which produces such output:

The brace is much too close to the matrix, how can I move it further away?

Here, I just add 6pt of vertical "stack gap" around the matrix.

\documentclass{article}
\usepackage{IEEEtrantools,stackengine}
\stackMath
\usepackage{amsmath}
\begin{document}
\begin{IEEEeqnarray*}{rClCl}
\left(
\begin{array}{c}
f\frac{X}{Z} \\ f\frac{Y}{Z}\\ 1
\end{array}
\right) & \sim &
\left(
\begin{array}{c}
fX \\ fY \\ Z
\end{array}
\right) & = & \underbrace{\addstackgap[6pt]{\left(
\begin{array}{cccc}
f & 0 & 0 & 0 \\
0 & f & 0 & 0 \\
0 & 0 & 1 & 0
\end{array}
\right)}}_{\text{Projection Matrix of $C$}} \left(\begin{array}{c} X \\ Y \\ Z \\ 1 \end{array}\right)
\end{IEEEeqnarray*}

\end{document}


However, one might also consider renewing \arraystretch to avoid cramping:

\documentclass{article}
\usepackage{IEEEtrantools,stackengine}
\stackMath
\usepackage{amsmath}
\begin{document}
{\renewcommand\arraystretch{1.4}
\begin{IEEEeqnarray*}{rClCl}
\left(
\begin{array}{c}
f\frac{X}{Z} \\ f\frac{Y}{Z}\\ 1
\end{array}
\right) & \sim &
\left(
\begin{array}{c}
fX \\ fY \\ Z
\end{array}
\right) & = & \underbrace{\addstackgap[6pt]{\left(
\begin{array}{cccc}
f & 0 & 0 & 0 \\
0 & f & 0 & 0 \\
0 & 0 & 1 & 0
\end{array}
\right)}}_{\text{Projection Matrix of $C$}} \left(\begin{array}{c} X \\ Y \\ Z \\ 1 \end{array}\right)
\end{IEEEeqnarray*}}

\end{document}


My reaction to the screenshot you posted wasn't, "the underbrace is too close to the matrix." Instead, my reactions were, "the line spacing inside the vectors and matrices is much too tight" and "the text below the underbrace should be set on two lines".

Given that your example doesn't make much use of the facilities of the IEEEeqnarray environment, I've simplified the code to employ only macros and environments provided by the amsmath package.

By increasing the value of \arraystretch, more visual prominence is given to the matrix and vectors. Not only does this make it easier to read what's inside the matrix and vectors, it also gives less visual prominence to the underbrace itself. And, by spreading the underbrace-related material across two rows, one gives more prominence to that material -- and less prominence to the brace...

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
\renewcommand\arraystretch{1.5}
\begin{pmatrix}
f\frac{X}{Z} \\ f\frac{Y}{Z}\\ 1
\end{pmatrix}
&\sim
\renewcommand\arraystretch{1.5}
\begin{pmatrix}
fX \\ fY \\ Z
\end{pmatrix}
= \underbrace{
\begin{pmatrix}
f & 0 & 0 & 0 \\
0 & f & 0 & 0 \\
0 & 0 & 1 & 0
\end{pmatrix}}_{\substack{\text{Projection Matrix} \\ \text{of $C$}}}
\renewcommand\arraystretch{1.2}
\begin{pmatrix}
X \\ Y \\ Z \\ 1
\end{pmatrix}
\end{align*}

\end{document}

• Admittedly, the array spacing is rather tight, but in your example, the brace is still irritatingly close to the matrix delimiters, in my view. Aug 13, 2015 at 15:14
• @oarfish - My approach was not to focus too much on what I view as merely a symptom of a larger issue, viz., a fairly problematic overall layout. By (i) increasing the vertical size of the matrix and vectors and (ii) shortening the length of the underbrace (achieved by spreading the material below the underbrace across two rows), I was trying to get at the root causes of the layout problems.
– Mico
Aug 13, 2015 at 15:29

You can use a phantom so the underbrace is below the whole construction.

I used equation*, which is better (and simpler) if no alignment is involved. Most important, I used pmatrix instead of array, that gives better spacing of the parentheses.

\documentclass{article}
\usepackage{IEEEtrantools}
\usepackage{amsmath}

\begin{document}
\begin{equation*}
\renewcommand{\arraystretch}{1.2} % because of the fractions
\begin{pmatrix}
f\frac{X}{Z} \\ f\frac{Y}{Z}\\ 1
\end{pmatrix}
\sim
\begin{pmatrix}
fX \\ fY \\ Z
\end{pmatrix}
=
\underbrace{
\begin{pmatrix}
f & 0 & 0 & 0 \\
0 & f & 0 & 0 \\
0 & 0 & 1 & 0
\end{pmatrix}
\vphantom{\begin{pmatrix} X \\ Y \\ Z \\ 1 \end{pmatrix}}
}_{\text{\makebox[0pt]{Projection Matrix of $C$}}}
\begin{pmatrix}
X \\ Y \\ Z \\ 1
\end{pmatrix}
\end{equation*}

\end{document}