Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How to put underbraces, inside the parenthesis of a matrix, to name both sides of the blocks?

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{array}
\begin{document}
.
.
.
\[
\left (
\begin{array}{rrr|rrr}
0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 \\
\end{array}
\right )
\]
\end{document}

I'm compiling the code in my university server, where I can't install new packages.

share|improve this question
1  
Please provide a MWE next time. Furthermore, what packages do you have installed now? –  Svend Tveskæg Mar 14 '13 at 13:03

2 Answers 2

up vote 9 down vote accepted

Here's another (TikZ-free) option:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{array}

\newcommand\undermat[2]{%
  \makebox[0pt][l]{$\smash{\underbrace{\phantom{%
    \begin{matrix}#2\end{matrix}}}_{\text{$#1$}}}$}#2}

\begin{document}

\[
\left (
\begin{array}{rrr|rrr}
0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 \\
\undermat{A}{0 & 0 & 0} & \undermat{B}{0 & 0 & 0} \\
\end{array}
\right )
\]

\end{document}

enter image description here

share|improve this answer

Your code was not a minimal working example (MWE) (It's missing \begin{document} and \end{document}. Please make it a habit to provide one.

You should really consider using the \tikzmark macro for this. There are already a lot of answers regarding this tikz-based macro on this site. (AFAIK, a package is on the way to completion based on this macro by Andrew Stacey. For instance you can read the related question: \underbrace at a strange place, spanning array columns which you can tailor to the code below:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture,baseline=(#1.base)]
  \node (#1) {\strut};}
\begin{document}
\[
\left (
\begin{array}{rrr|rrr}
0 & 0 & 0 &\tikzmark{upper1} 0 & 0 & 0\tikzmark{upper2} \\
0 & 0 & 0 & 0 & 0 & 0 \\
\tikzmark{lower1}0 & 0 & 0\tikzmark{lower2} & 0 & 0 & 0 \\
\end{array}
\right )
\]

\begin{tikzpicture}[overlay, remember picture,decoration={brace,amplitude=5pt}]
\draw[decorate,thick] (lower2.south) -- (lower1.south)
      node [midway,below=5pt] {Left block};
\draw[decorate,thick] (upper1.north) -- (upper2.north)
      node [midway,above=5pt] {Right block};
\end{tikzpicture}
\end{document}

enter image description here

You have to compile this twice to see the same output.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.