I am trying to achieve having overbraces and right braces to a matrix to explain columns and rows. This is what I achieved so far :
This is the code I have used :
\documentclass{article}
\usepackage{amsmath}
\newcommand\overmat[2]{%
\makebox[0pt][l]{$\smash{\color{white}\overbrace{\phantom{%
\begin{matrix}#2\end{matrix}}}^{\text{\color{black}#1}}}$}#2}
\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{matrix}
\begin{pmatrix}
\bovermat{$m_1$ colonnes}{\lambda_1 & 0 & \ldots & 0 & 0} & \bovermat{$n - m_1$ colonnes}{ & & & & } \\[0.5em]
%
0 & \lambda_1 & \ldots & 0 & 0 & & & & & \\[0.5em]
%
0 & 0 & \ddots & 0 & 0 & & & \mbox{\Huge U} & & \\[0.5em]
%
0 & 0 & \ldots & \lambda_1 & 0 & & & & & \\[0.5em]
%
0 & 0 & \ldots & 0 & \lambda_1 & & & & & \\[0.5em]
%
& & & & & & & & & \\[0.5em]
%
& & & & & & & & & \\[0.5em]
%
& & \mbox{\Huge O} & & & & & \mbox{\Huge V} & & \\[0.5em]
%
& & & & & & & & & \\[0.5em]
%
& & & & & & & & & \\[0.5em]
\end{pmatrix}
\begin{aligned}
&\left.\begin{matrix}
\partialphantom \\[0.5em]
\partialphantom \\[0.5em]
\partialphantom \\[0.5em]
\partialphantom \\[0.5em]
\partialphantom \\[0.5em]
\end{matrix} \right\} %
m_1 \text{ lignes}\\
&\left.\begin{matrix}
\partialphantom \\[0.5em]
\partialphantom \\[0.5em]
\partialphantom \\[0.5em]
\partialphantom \\[0.5em]
\partialphantom \\[0.5em]
\end{matrix}\right\}%
n - m_1 \text{ lignes}\\
\end{aligned}
\end{matrix}$
\end{document}
Now the only problem I have, is that I would want the first overprice to encompass up to the last zero on the first line of the matrix and the second brace should start at the end of the first and go up to the end of the matrix.
I am however at a total loss on how I should be doing it.
Any help would be appreciated.
\partialphantom
command?\newcommand\partialphantom{\vphantom{\frac{\frac{\partial e_{P,M}}}{\partial w_{1,1}}}
update your code with the definition of this macro.