[Tex/LaTex] How to adjust \underbrace spacing

amsmathbracesmath-mode

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:

enter image description here

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

Best Answer

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}

enter image description here

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}

enter image description here