Angle brackets with an underset arrow

The following example centers the left and right annotation text below the delimiters and puts an extensible arrow between. The example uses package amsmath and defines the following environments:

  • Environment amatrix sets a matrix with angle brackets as delimiters, similar to environments bmatrix, pmatrix of package amsmath.
  • Environment amatrixarrow takes one optional and two mandatory arguments and sets the annotations below the matrix connected by an arrow.

    \begin{amatrixarrow}[0.25ex]{left}{right} ... \end{amatrixarrow}
    

    The optional argument specifies the distance between matrix and annotation. The default is 0.5ex of the annotation's font size and can be overwritten by the optional argument.

Example file:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newenvironment{amatrix}{%
  \left\langle
  \env@matrix
}{%
  \endmatrix
  \right\rangle
}

\newcommand{\amatrixarrow}[3][.5ex]{%
  \def\amatrixarrow@shift{#1}%
  \def\amatrixarrow@left{#2}%
  \def\amatrixarrow@right{#3}%
  \collect@body\amatrixarrow@next
}
\newcommand*{\amatrixarrow@next}[1]{%
  \mathpalette{\amatrixarrow@}{#1}%
}
\newcommand*{\amatrixarrow@}[2]{%
  % #1: math style (\displaystyle, \textstyle, ...)
  % #2: environment body
  \sbox0{$\m@th#1\begin{amatrix}#2\end{amatrix}$}%
  \sbox2{$\m@th#1\begin{matrix}#2\end{matrix}$}%
  \sbox4{$\m@th
    \amatrixarrow@style{#1}%
    \amatrixarrow@left
  $}%
  \sbox6{$\m@th
    \amatrixarrow@style{#1}%
    \amatrixarrow@right
  $}%
  \sbox8{$\m@th\amatrixarrow@style{#1}\text{\kern\amatrixarrow@shift}$}%
  \dimen0=.5\dimexpr\wd0-\wd2\relax
  \vtop{%
    \hbox{%
      \kern.5\dimexpr\wd4-\dimen0\relax
      % \fboxsep=0pt\fboxrule=.1pt \fbox{\copy0 }%
      \copy0 %
    }%
    \kern\wd8 %
    \nointerlineskip
    \hbox to \dimexpr\wd0+.5\wd4+.5\wd6-\dimen0\relax{%
      \copy4 %
      \hfill
      \sbox2{$\m@th
        \amatrixarrow@style{#1}%
        {}\xrightarrow{}{}%
      $}% shortest arrow with spacing
      $\m@th
        \amatrixarrow@style{#1}%
        \xrightarrow{%
          \kern\dimexpr\wd0-.5\wd4-.5\wd6-\dimen0-\wd2\relax
        }%
      $%
      \hfill
      \copy6 %
    }%
  }%
}
\newcommand*{\amatrixarrow@style}[1]{%
  \ifx#1\displaystyle
    \scriptstyle
  \else\ifx#1\textstyle
    \scriptstyle
  \else
    \scriptscriptstyle
  \fi\fi
  % #1%
}
%\renewcommand*{\amatrixarrow@style}[1]{#1}
\makeatother

\begin{document}
\[
  {\begin{amatrixarrow}[0ex]{2\oplus 1\oplus 1}{4\oplus 2\oplus 4}
    bc - ad & bb - aa & ca + bd \\
    0       & b - a   & 0       \\
    0       & 2a      & 0
  \end{amatrixarrow}}
\Rightarrow
  {\begin{amatrixarrow}{3}{3\oplus 3}
    abc - acb & abc - bac
  \end{amatrixarrow}}
\]
\end{document}

Result

Variant without decreased font size for annotation

I think the annotation looks better in a smaller math style. But it is possible to keep the current math style by changing the definition of \amatrixarrow@style to:

\newcommand*{\amatrixarrow@style}[1]{#1}

Result

Remarks (for the more experienced):

  • The environment amatrixarrow catches its body by amsmath's \collect@body. Then the environment contents can be used twice, in a matrix without delimiters and in amatrix with angle brackets. The horizontal position for the annotations are calculated by comparing the widths of the two matrices.

  • By using \vtop with the matrix as first element, the reference point of the matrix remains unchanged. The annotations just enlarge the depth of the whole construct.

  • \mathpalette provides the current math style.
  • The reason for the optional parameter is, that it is not known, how many white space the matrix contains at the bottom. Internally the matrix is implemented using environment array that automatically adds invisible struts. The depth of the strut in the bottom line might increase the optical distance between the annotations and the bottom of the matrix, as seen in the first matrix of the example.

  • In the example the environment amatrixarrow is put in curly braces to protect it from the parent environment align*.

  • The arrow is drawn via \xrightarrow with the spacing of the arrow as relational symbol.


This is not yet perfect but using tikzyou can do so:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,calc}
\begin{document}

\begin{tikzpicture}
\matrix (m)[matrix of math nodes,left delimiter={\langle},right delimiter={\rangle}]
    {  A  & B  & C+1  \\
       A' & B' &C' \\ };
\draw($(m.south west)-(0,0.1)$) node(a) {$x$};
\draw($(m.south east)-(0,0.1)$) node(b) {$y$};
\draw[->] (a)  edge (b);
\end{tikzpicture}

\end{document}

With result

enter image description here


A slight improvement over @yann.pequignot's solution, using the label key to position texts under the backets. Note that since TikZ cannot make & given in the argument to an active character, \& is used instead as a column separator.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\newcommand\imfun[3]{
\begin{tikzpicture}
\tikzset{
  every left delimiter/.style={
    xshift=1ex,label={[name=lb,label distance=-5pt,minimum height=2em]below:$#1$}
  },
  every right delimiter/.style={
    xshift=-1ex,label={[name=rb,label distance=-5pt,minimum height=2em]below:$#2$}
  }
}

\matrix [ampersand replacement=\&,matrix of math nodes,
left delimiter=\langle,right delimiter=\rangle]
{#3};
\draw[->](lb)--(rb);
\end{tikzpicture}
}

\imfun{2\oplus1\oplus1}{4\oplus2\oplus4}{
  bc-ad \& bb-aa \& ca+bd \\
  0 \& b-a \& 0 \\
  0 \& 2a \& 0 \\
}

\imfun{3}{3\oplus3}{abc-acb \& abc-bac\\}
\end{document}

enter image description here