Put left brace in nicematrix

bracesmatricesnicematrix

I want to have a matrix, where on the left side I have left brace with n written on it. But the current code I have does not produce the desired result. The left brace is not drawn due to some issue with SubMatrix, and moreover, submatrices \mathbf{A}_1 and \mathbf{A}_2 are moved one column to the right. Any idea how to do this?

\documentclass{article}
\usepackage{amsmath,nicematrix}
\begin{document}
\[ 
    \begin{bNiceArray}[last-col,margin]{w{c}{5em}|w{c}{3em}}
    \\
    \hspace*{-3cm} n & \mathbf{A}_1 & \mathbf{A}_2 \\
    \\
    \CodeAfter
    \OverBrace[yshift=5pt]{1-1}{2-2}{\mathbf{A}}
    \UnderBrace[yshift=5pt]{1-1}{3-1}{m_2}
    \UnderBrace[yshift=5pt]{2-2}{3-2}{m_1}
    \SubMatrix{\{}{1-1}{3-2}{.}[left-xshift=22pt]
    \end{bNiceArray}
\]
\end{document}

Best Answer

You probably wanted to use first-col and not last-col...

\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\[ 
    \begin{bNiceArray}[first-col,margin]{w{c}{5em}|w{c}{3em}}
    \\
    n\hspace*{3mm} & \mathbf{A}_1 & \mathbf{A}_2 \\
    \\
    \CodeAfter
      \OverBrace[yshift=5pt]{1-1}{2-2}{\mathbf{A}}
      \UnderBrace[yshift=5pt]{1-1}{3-1}{m_2}
      \UnderBrace[yshift=5pt]{2-2}{3-2}{m_1}
      \SubMatrix{\{}{1-1}{3-2}{.}[left-xshift=27pt]
    \end{bNiceArray}
\]
\end{document}

Output of the above code

Related Question