0

I need to create a matrix and some overbraces on some entries at the top of the matrix like the following image(the entries are omitted)

enter image description here

I tried this code

$$  
A_n = \begin{bmatrix}
a_1&b_{1,2}&\overbrace{0, \cdots, 0}^{N_1-1}&b_{1,S_1+1}&\overbrace{0, \cdots, 0}^{N_2-1}
\end{bmatrix}
$$

and this was the result. I don't want the overbrace to be inside the matrix

enter image description here

How can I do that?

M a m a D
  • 191
  • 2
    In mathmode the symbol $$...$$ is depreciated. https://tex.stackexchange.com/questions/503/why-is-preferable-to – Sebastiano Aug 16 '18 at 05:43
  • You can see here https://tex.stackexchange.com/questions/15825/how-to-specify-two-level-row-and-column-labels-of-a-matrix-by-braces or https://tex.stackexchange.com/questions/40/how-do-i-label-different-rows-or-columns-of-a-matrix-using-braces – Sebastiano Aug 16 '18 at 05:46

1 Answers1

4

May be this will help you (adapted from this answer):

\documentclass{article}
\usepackage{amsmath}
\newcommand\bovermat[2]{%
    \makebox[0pt][l]{$\smash{\overbrace{\phantom{%
                    \begin{matrix}#2\end{matrix}}}^{\text{#1}}}$}#2}
\newcommand\partialphantom{\vphantom{\frac{\partial e_{P,M}}{\partial w_{1,1}}}}
\begin{document}
\begin{equation}
\begin{matrix}
    A_n
    =
    \begin{bmatrix}
    a_1&b_{1,2}&\bovermat{1}{0,\cdots,0} & b_{1,s_{1}+1} &
    \bovermat{2}{0,\cdots,0}\\
    \end{bmatrix}
    \end{matrix}
    \end{equation}
\end{document}

which gives:

enter image description here