How to set name above a part of a matrix? [closed]

I want to create the matrix that is shown in the image, and my code is:

$$B= \begin{pmatrix} \begin{array}{ccc|ccc} 0 & \cdots & 0 & 0 & \cdots & 0\\ & R & & & A & \\ \hline & 0 & & & 0 & \end{array} \end{pmatrix}$$

It works, and makes the matrix, but I don't know how to create the labels above or next to the blocks.

closed as off-topic by Matthew Towers, JonMark Perry, Saad, GNUSupporter 8964民主女神 地下教會, user223391 Apr 29 '18 at 1:16

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question does not appear to be about Mathematics Stack Exchange or the software that powers the Stack Exchange network within the scope defined in the help center." – Matthew Towers, JonMark Perry, Saad, GNUSupporter 8964民主女神 地下教會, Community
If this question can be reworded to fit the rules in the help center, please edit the question.

• You may have more success with this at tex.stackexchange.com. – Peter Phipps Apr 17 '18 at 10:03
• This is effectively not possible with MathJax right now since it does not yet have implemented colspan and rowspan. The way right now is to manually hack the correct placement. If you move the braces inside, you could simply create a 2x2 matrix for B and use overparen etc in the relevant cell. – Peter Krautzberger Apr 17 '18 at 10:52
• Posting this question at tex.stackexchange.com might result in several different ways this can be done. Some of those may require a level of TeX sophistication beyond what you're willing to work with, or have more bells and whistles than what is reasonable for the context in which you're working, but some may be useful. – Michael Hardy Apr 20 '18 at 16:28

Here is one way to do it, though it is a hack.

B=\left(
\begin{array}{c|c}
0\,\cdots\, 0 & \smash{\overbrace{0\,\cdots\, 0\strut}^p}\\
R & A\\
\hline
0 & 0
\end{array}
\right)\!\!\raise .7em{\bigg\}\vcenter{\scriptstyle p}}
\Rule{0em}{3.4em}{0em}

which produces:

$$B=\left( \begin{array}{c|c} 0\,\cdots\, 0 & \smash{\overbrace{0\,\cdots\, 0\strut}^p}\\ R & A\\ \hline 0 & 0 \end{array} \right)\!\!\raise.7em{\bigg\}\vcenter{\scriptstyle p}} \Rule{0em}{3.4em}{0em}$$

• Very cool. Thanks for proving me wrong ;-) – Peter Krautzberger May 17 '18 at 6:39