# How to use braces at left and top of array in equation mode?

I tried to put 2 braces, one at the top and one at the left, but I got an ugly effect. How to fit both braces with the array?

\documentclass[12pt]{report}
\begin{document}
$$lines \overbrace{\left\{\begin{array}{|r|r|r|r|r|} \hline 4 & 6 & 5 & 7 & 9 \\ \hline 3 & 5 & 7 & 8 & 10 \\ \hline 1 & 3 & 9 & 10 & 12 \\ \hline 2 & 4 & 3 & 9 & 11 \\ \hline \end{array}\right.}^{columns}$$
\end{document}


An rude solution, similar to solution which Barbara Beeton pointed in her comment:

\documentclass[12pt]{report}
\begin{document}
$$lines \left\{\vphantom{\begin{array}{c} \hline 4 \\ \hline 3 \\ \hline 1 \\ \hline 2 \\ \hline \end{array}}\right.% \overbrace{\begin{array}{|r|r|r|r|r|} \hline 4 & 6 & 5 & 7 & 9 \\ \hline 3 & 5 & 7 & 8 & 10 \\ \hline 1 & 3 & 9 & 10 & 12 \\ \hline 2 & 4 & 3 & 9 & 11 \\ \hline \end{array}}^{columns}$$
\end{document}

• As you pointed, similar. But in fact, better, because make use of all first column with \vphantom. – Vitor Abella Aug 12 '16 at 20:23

Here is another solution, based on blkarray:

\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}%
\usepackage{blkarray, amsmath}

\begin{document}

$$\renewcommand\arraystretch{1.6} \overbrace{\mkern-8mu\begin{blockarray}{rrrrr}% \hphantom{10}& \hphantom{10} &\hphantom{10} & & \\[-4ex] \begin{block}{\Left{\footnotesize lines\,}{\{\hspace{0.8em}}|r|r|r|r|r|} \BAhline 4 & 6 & 5 & 7 & 9 \\ \BAhline 3 & 5 & 7 & 8 & 10 \\ \BAhline 1 & 3 & 9 & 10 & 12 \\ \BAhline 2 & 4 & 3 & 9 & 11 \\ \BAhline \end{block} \end{blockarray}\mkern-8mu}^\text{columns}%$$

\end{document}