How can I make LaTeX ignore height of underbrace?

A solution using TikZ for diagonal braces:

\documentclass{article}
\usepackage{amsmath,array}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}

\setlength\arraycolsep{4pt} % default value: 6pt

\newcommand\tikzmark[1]{%
  \tikz[overlay,remember picture,baseline] \coordinate [anchor=base] (#1);}

\newcommand\DrawBrace[3]{%
  \draw [decorate,decoration={brace,amplitude=2pt,mirror,raise=2pt}]
    (#1) -- (#2) node [black,midway,sloped,yshift=-10pt] {\footnotesize$#3$};
}

\begin{document}

\begin{equation*}
\left(
\begin{array}{*{9}{c}}
\tikzmark{a}\phantom{-}1 \\
& \ddots & \\
& & \tikzmark{b}\phantom{-}1 \\
& & & \tikzmark{c}-1 \\
& & & & \ddots & \\
& & & & & \tikzmark{d}-1\\
& & & & & & \tikzmark{e}\phantom{-}0 \\
& & & & & & & \ddots & \\
& & & & & & & & \tikzmark{f}\phantom{-}0 \\
\end{array}
\right)
\end{equation*}

\begin{tikzpicture}[remember picture,overlay]
\DrawBrace{a}{b}{r_{+}(s)-mal}
\DrawBrace{c}{d}{r_{-}(s)-mal}
\DrawBrace{e}{f}{r_{0}(s)-mal}
\end{tikzpicture}
\end{document}

enter image description here


Not really an elegant solution. Basically, all that is needed is to set the additional vertical space produced by the \underbrace to zero. One easy tool for this is \raisebox which in its first and second optional argument allows to give an explicit height and depth for the resulting box.

Two complications:

  1. The inner array comes out vertically centered, so the height and depth of the \underbrace construct are murky.
  2. Some additional vertical space is inserted in the outer array if one of the lines has depth zero, so the whole boxed construct must be lowered again.

This leads to this "solution":

\begin{equation*}
\left( \,
\begin{array}{r@{}r@{}r r r}  % @{} is used twice to suppress intercolumn whitespace
  \overbrace{
    \boxed{
      \begin{array}{rrr}    % First block (1)
        1 &        &   \\
          & \ddots &   \\
          &        & 1 \\
      \end{array}
    }
  }^{r_+(s)-mal} \\
  & 
  \raisebox{-.5\height}[.5\height][.5\height]
  {%
    $\underbrace{
      \raisebox{\depth}
      {%
        $\boxed{
          \begin{array}{rrr}    % Second block (-1)
            -1 &        &   \\
            & \ddots &   \\
            &        & -1\\
          \end{array}
        }$%
      }%
    }_{r_{-}(s)-mal}$%
  }%
  \\
  & & 
  \underbrace{
    \boxed{
      \begin{array}{rrr}    % Third block
        0  &        &  \\
           & \ddots &  \\
           &        & 0\\
      \end{array}
    }
  }_{r_0(s)-mal} \\
\end{array}\,\right)
\end{equation*}

example


There must be a tikzmark way. But I don't have time now. Meanwhile, an ugly hack will be to manually shrink the space using \\[length] as in

\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{2mm}

\usepackage{amsmath,array}
\renewcommand\arraycolsep{4pt} % default value: 6pt


\begin{document}
\begin{preview}
\begin{equation*}
\left( \,
\begin{array}{r@{}r@{}r r r}  % @{} is used twice to suppress intercolumn whitespace
  \overbrace{
    \boxed{
      \begin{array}{rrr}    % First block (1)
        1 &        &   \\
          & \ddots &   \\
          &        & 1 \\
      \end{array}
    }
  }^{r_+(s)-mal} \\
  &
  \underbrace{
    \boxed{
      \begin{array}{rrr}    % Second block (-1)
        -1 &        &   \\
           & \ddots &   \\
           &        & -1\\
      \end{array}
    }
  }_{r_{-}(s)-mal} \\[-17pt]         %%% <--Here
  & &
  \underbrace{
    \boxed{
      \begin{array}{rrr}    % Third block
        0  &        &  \\
           & \ddots &  \\
           &        & 0\\
      \end{array}
    }
  }_{r_0(s)-mal} \\
\end{array}\,\right)
\end{equation*}
\end{preview}
\end{document}

enter image description here

Little eye-balling would be needed to estimate the appropriate value for \\[-17pt], though.