TransWikia.com

Overbrace and right braces to explain matrix

TeX - LaTeX Asked by Sephya on September 3, 2021

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 :

Matrix

This is the code I have used :

documentclass{article}
usepackage{amsmath}

newcommandovermat[2]{%
makebox[0pt][l]{$smash{color{white}overbrace{phantom{%
begin{matrix}#2end{matrix}}}^{text{color{black}#1}}}$}#2}
newcommandbovermat[2]{%
makebox[0pt][l]{$smash{overbrace{phantom{%
begin{matrix}#2end{matrix}}}^{text{#1}}}$}#2}
newcommandpartialphantom{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.

One Answer

Complicated, but doable.

documentclass{article}
usepackage{amsmath}

begin{document}

[
% some local definitions
newcommandexplainA{%
  overbrace{%
    hphantom{begin{matrix}lambda_1&lambda_1&dots&lambda_1&lambda_1end{matrix}}%
  }^{text{$m_1$ colonnes}}%
}
newcommand{explainB}{%
  overbrace{%
    hphantom{begin{matrix}0&0&0&0&0end{matrix}}%
  }^{text{$n-m_1$ colonnes}}%
}
newcommand{explainC}{%
  left.vphantom{begin{matrix}0ddotsend{matrix}}right}%
  text{scriptsize$m_1$ lignes}%
}
newcommand{explainD}{%
  left.vphantom{begin{matrix}0end{matrix}}right}%
  text{scriptsize$n-m_1$ lignes}%
}
settowidth{dimen0}{%
  $begin{pmatrix}vphantom{begin{matrix}0end{matrix}}end{pmatrix}$%
}
settowidth{dimen2}{$explainB$}
begin{matrix}
begin{matrix}hspace*{0.5dimen0}explainA&explainBhspace*{0.5dimen0}end{matrix}
[-0.5ex]
begin{pmatrix}
begin{matrix}
lambda_1 & 0 & dots & 0 & 0 
0 & lambda_1 & dots & 0 & 0 
0 & 0 & ddots & 0 & 0 
0 & 0 & dots & lambda_1 & 0 
0 & 0 & dots & 0 & lambda_1
end{matrix}
&
makebox[dimen2]{Huge$U$} 
vphantom{begin{matrix}0end{matrix}}text{Huge$O$} & text{Huge$V$}
end{pmatrix}
&hspace*{-1em}begin{matrix} explainChfill  explainD end{matrix}
end{matrix}
]

end{document}

You might enjoy studying it. There are two “guesses”: the amount by which the top line should be lowered and the amount by which the explanations on the right have to be pushed left.

enter image description here

I think it would be simpler to just write the block matrix and give the explanation of the sizes in the text.

Correct answer by egreg on September 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP