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.

I recently started learning LaTeX and though I found answers for almost all of my questions by looking online (and especially here), there is still one more thing I would like to be able to do but can't for the article I am writing:

I would like to be able to specify the dimensions and the "subdimensions" below a matrix. To be clearer, let us take the following example:

$ D =
  \underbracket{\begin{pmatrix}
   D_1 & 0      & 0   &   &        &    \\
   0   & \ddots &     &   &    {\textrm{\huge 0}}    &    \\
   0   & 0      & D_n &   &        &    \\
       &        &     &   &        &    \\
       &   \textrm{\huge 0}     &     &   &   {\textrm{\huge 0}}     &    \\
       &        &     &   &        &    \\
  \end{pmatrix}}_N $

this gives a nice matrix whith the dimension N specified as a bracket under the matrix. That is fine, however I would like to add a second bracket to specify the smaller dimension n of the inner block matrix right below the matrix (and possibly above the first main bracket) which is shorter, i.e. I would like it to extend from 1 to n and not all the way below the matrix.

I am open to any solution, but the simpler the better for me :)

share|improve this question
1  
Welcome to TeX.SE!. Do you think you can complete your code to make it a MWE, starting with \documentclass{} and ending with \end{document}, making sure you include any packages that are required to compile the above code? –  Vivi Dec 18 '12 at 3:11

3 Answers 3

up vote 3 down vote accepted

The following is not really eye-candy, but it's probably what you're after:

enter image description here

\documentclass{article}
\usepackage{mathtools}% http://ctan.org/pkg/mathtools
\begin{document}
\[
D =
  \underbracket{\begin{pmatrix}
   D_1 & 0      & 0   &   &        &    \\
   0   & \ddots &     &   &    {\textrm{\huge 0}}    &    \\
   0   & 0      & D_n &   &        &    \\
       &        &     &   &        &    \\
       &   \textrm{\huge 0}     &     &   &   {\textrm{\huge 0}}     &    \\
       &        &     &   &        &    \\
  \end{pmatrix}}_N
\]

\[
  D= \underbracket[.4pt]{\left(\begin{array}{@{}c@{\quad}c}
    \underbracket[.4pt]{\begin{array}{ccc}
      D_1 & \vphantom{\ddots}0 & 0 \\
      0 & \ddots & 0 \\
      0 & \vphantom{\ddots}0 & D_n
    \end{array}}_{n} & \text{\huge 0} \\ \\
    \text{\huge 0} & \text{\huge 0}
  \end{array}\right)}_{N}
\]
\end{document}

The use of \vphantom ensure that the row height for the "inner matrix" is similar across all rows (without actually printing \ddots).

I went with a more traditional approach (using array), rather than pmatrix. The advantage is that you have control over the alignment.

share|improve this answer

Please always post complete documents showing all packages used. I couldn't locate underbracket. there appears to be a spurious right hand column affecting the spacing of the delimiter, also I removed some superfluous braces.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}

$ D =
  \begin{pmatrix}
   D_1 & 0      & 0   &   &           \\
   0   & \ddots &     &   & \textrm{\huge 0} \\
   0   & 0      & D_n &   &        &    \\
\multicolumn{3}{c}{$\upbracefill$}&\\
\multicolumn{3}{c}{\scriptstyle n}&\\
       &        &     &   &        \\
       &   \textrm{\huge 0}     &     &   & \textrm{\huge 0} \\
\multicolumn{6}{c}{$\upbracefill$}\\
\multicolumn{6}{c}{\scriptstyle N}\\
\noalign{\vspace{-2\normalbaselineskip}}
  \end{pmatrix} $\vspace{2\normalbaselineskip}

\end{document}
share|improve this answer
    
\underbracket is part of mathtools, just for the record. –  Max Dec 18 '12 at 5:26
    
@DavidCarlisle -- your result, while "accurate", is unappealingly uneven. i added another answer with some prettifying that you're welcome to incorporate if you like; i would have just commented, but the code would have been undecipherable in a comment. (well, maybe not for you ...) –  barbara beeton Dec 18 '12 at 17:28

this is really the same as david's answer, but is prettied up a bit:

output of example code

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[
 D =
  \begin{pmatrix}
   \;D_1 & 0      & 0   &   &        &   \\[-.5ex]
     0   & \clap{$\ddots$} &     &   & \raisebox{-1ex}{\huge 0} & \strut\enspace 
\\[4pt]
     0   & 0      & D_n &   &        &    \\
\multicolumn{3}{c}{$\upbracefill$}&\\
\multicolumn{3}{c}{\scriptstyle n}&\\
         &        &     &   &        \\
         &   \textrm{\huge 0}     &     &   & \textrm{\huge 0} & \\
\multicolumn{6}{c}{$\upbracefill$}\\
\multicolumn{6}{c}{\scriptstyle N}\\
\noalign{\vspace{-2\normalbaselineskip}}
  \end{pmatrix} 
\vspace{2\normalbaselineskip}
\]
\end{document}
share|improve this answer
    
+1 for making me pretty –  David Carlisle Dec 18 '12 at 17:34

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.