3

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 :)

1
  • 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, 2012 at 3:11

4 Answers 4

3

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.

5

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}
2
  • \underbracket is part of mathtools, just for the record.
    – Max
    Dec 18, 2012 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 ...) Dec 18, 2012 at 17:28
3

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}
0
0

Here is what you can do with {pNiceMatrix} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

$D = \begin{pNiceMatrix}[margin,columns-width=auto,nullify-dots]
  D_1 & 0      & 0   & \Block{3-3}<\LARGE>{0} & & \\
  0   & \Ddots & 0   \\
  0   & 0      & D_n \\
  \\
  \Block{3-3}<\LARGE>{0} & & & \Block{3-3}<\LARGE>{0} \\
  \\
  \\
\CodeAfter 
  \UnderBrace{1-1}{3-3}{n}
  \UnderBrace[yshift=2mm]{7-1}{7-6}{N}
\end{pNiceMatrix}$

\end{document}

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .