4

I am trying to put braces on matrix that cover just few rows or columns.

I have come kinda close for the columns but no idea for the rows.

This is the example I have been working on:

\documentclass{minimal}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
A = \begin{array}{c@{\!\!\!}l}
\left( \begin{array}[c]{ccc}
a1 & \cdots & aN\\
b1 & \cdots & bN\\
\vdots &  & \vdots\\
z1 & \cdots & zN \\

\end{array}  \right)

&
\begin{array}[c]{ll}
\left. \begin{array}{c} \vphantom{1cm}  \\ \vphantom{2*\vdots}
\\ \vphantom{1cm} \end{array} \right\} & \text{$n_1$ times} \\

\end{array}
\end{array}
\end{equation*}

\end{document}

which produces this:

enter image description here

Does anyone have any idea?

5 Answers 5

4

If you want to span only some rows, you can use nicematrix which will put a Tikz node behind each cell of the matrix and then use the commands of Tikz to draw the brace and its label.

\documentclass{minimal}
\usepackage{nicematrix,tikz}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{equation*}
A = \begin{pNiceMatrix}%
a1 &\Hdotsfor{2} & aN\\
b1 &\Hdotsfor{2} & bN\\
\Vdots & & & \Vdots\\
z1 & \Cdots &\Cdots & zN \\
\CodeAfter
   \tikz
   \draw [decorate,decoration = brace]
        ([xshift=3mm]2-4.north east) to node [auto = left] {$n_1$ times} 
        ([xshift=3mm]4-4.south east) ;
\end{pNiceMatrix}
\end{equation*}
\end{document}

enter image description here

1
  • Yes! nicematrix is definitely the way to go. However I couldn't compile your code, could you revisit it?.
    – Fabio
    Aug 14, 2018 at 16:55
4

If you want to span all rows of a matrix, you have the rcases environment from mathtools (an extension of amsmath), which also simplifies the code for a matrix, with its pmatrix environment. I added some improvements, as I think the matrix looks nicer with 4 columns:

\documentclass{minimal}
\usepackage{mathtools}

\begin{document}

\begin{equation*}
\begin{rcases}\displaystyle
A = \begin{pmatrix}
a1 &\hdotsfor{2} & aN\\
b1 &\hdotsfor{2} & bN\\
\vdots & & & \vdots\\
z1 & \cdots &\cdots & zN \\
\end{pmatrix}
\end{rcases}
 \text{$n_1$ times}
\end{equation*}

\end{document}

enter image description here

2

You can construct a zero-width array next to your matrix containing elements that match the height of the matrix rows. This way you can place a \right\} where needed:

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\[
  A = \begin{pmatrix}
      a_1  & \cdots &   a_N  \\
      b_1  & \cdots &   b_N  \\
    \vdots &        & \vdots \\
      z_1  & \cdots &   z_N  \\
  \end{pmatrix}
  \setlength{\arraycolsep}{0pt} % Avoid any column space in arrays that follow
  \begin{array}{ c }
    \vphantom{a_N} \\ % First row
    \left.\kern-\nulldelimiterspace
    \vphantom{\begin{array}{ c }
        b_N  \\ % Second row
      \vdots \\ % Third row
        z_N     % Fourth/last row
    \end{array}}
    \right\}\text{$n_1$ times}
  \end{array}
\]

\end{document}
0

This is the code that worked out for me.

\documentclass{minimal}
\usepackage{nicematrix}
\NiceMatrixOptions{transparent}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}

\begin{equation*}
A=\begin{pNiceMatrix}[name=matrix]
a1 &\hdotsfor{2} & aN\\
b1 &\hdotsfor{2} & bN\\
\vdots & & & \vdots\\
z1 & \cdots &\cdots & zN \\
\end{pNiceMatrix}
\tikz[remember picture,overlay]
\draw[decoration={brace},decorate,thick]  ([xshift=3mm]matrix-2-4.north east) -- node[right=6pt] {$n_1$ times} ([xshift=3mm]matrix-4-4.south east);
\end{equation*}

\end{document}
2
  • I can compile your code but I can also compile the code of my answer. What is the error messsage you get? If you want, you can send me the log file. My email : fpantigny@wanadoo.fr Aug 14, 2018 at 18:25
  • The error is "Package pgf Error: No shape named 2-4 is known". and the same for 4-4. I'll send you the log file.
    – Fabio
    Aug 17, 2018 at 22:10
0

With version of nicematrix at least 5.16 (2021-06-20), it's also possible to provide a solution which does not use explicitely Tikz. The brace is a standard brace of LaTeX and not a brace of the Tikz library decorations.

\documentclass{minimal}
\usepackage{nicematrix}
\begin{document}
\begin{equation*}
A = 
\begin{NiceArray}{(ccc)@{\qquad}l}[nullify-dots]
    a1     & \Ldots        & aN     & \\
    b1     & \Ldots        & bN     & \\
    \Vdots & \hspace*{1cm} & \Vdots & n_1 \text{ times}\\
    z1     & \Cdots        & zN  \\
\CodeAfter
    \SubMatrix{.}{2-3}{4-3}{\rbrace}[xshift=3mm]
\end{NiceArray}
\end{equation*}
\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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