TeX - LaTeX Asked by Adam Gosztolai on June 15, 2021
I have managed to create under braces under my matrix and evened out the spaced using phantom
.
However, there are very large spaces between the columns, the dots, and the brackets. It would be great to make everything more compact horizontally, but I have no idea how to do so.
Could someone help?
newcommand*{vertbar}{rule[-1ex]{0.5pt}{2.5ex}}
newcommandundermat[2]{% http://tex.stackexchange.com/a/102468/5764
makebox[0pt][l]{$smash{underbrace{phantom{%
begin{matrix}#2end{matrix}}}_{text{$#1$}}}$}#2}
begin{align}
mathbf{W}_{BA} &
begin{pmatrix}
vertbar & & vertbar & & vertbar & & vertbar
mathbf{x}^B_1 & dots & mathbf{x}^B_1 & dots & mathbf{x}^B_p & dots & mathbf{x}^B_p
undermat{k}{vertbar & & phantom{--}vertbarphantom{--}} & & undermat{k}{vertbar & & {phantom{--}vertbarphantom{--}}}
end{pmatrix}
= notag \
& begin{pmatrix}
vertbar & & vertbar & & vertbar & & vertbar
mathcal{N}(mathbf{x}^B_1)_1 & dots & mathcal{N}(mathbf{x}^B_1)_k & dots & mathcal{N}(mathbf{x}^B_p)_1 & dots & mathcal{N}(mathbf{x}^B_p)_k
undermat{k}{vertbar & & phantom{---}vertbarphantom{---}} & & undermat{k}{vertbar & & {phantom{---}vertbarphantom{---}}}
end{pmatrix}.
end{align}
Below I use some measurements to correctly align the underbrace
width with its contents.
documentclass{article}
usepackage{amsmath,xcolor}
newcommand*{vertbar}{rule[-1ex]{0.5pt}{2.5ex}}
newcommandundermat[2]{% http://tex.stackexchange.com/a/102468/5764
makebox[0pt][l]{$smash{underbrace{phantom{%
begin{matrix}#2end{matrix}}}_{text{$#1$}}}$}#2}
begin{document}
Original:
begin{align}
mathbf{W}_{BA} &
begin{pmatrix}
vertbar & & vertbar & & vertbar & & vertbar
mathbf{x}^B_1 & dots & mathbf{x}^B_1 & dots & mathbf{x}^B_p & dots & mathbf{x}^B_p
undermat{k}{vertbar & & phantom{--}vertbarphantom{--}} & & undermat{k}{vertbar & & {phantom{--}vertbarphantom{--}}}
end{pmatrix}
= notag \
& begin{pmatrix}
vertbar & & vertbar & & vertbar & & vertbar
mathcal{N}(mathbf{x}^B_1)_1 & dots & mathcal{N}(mathbf{x}^B_1)_k & dots & mathcal{N}(mathbf{x}^B_p)_1 & dots & mathcal{N}(mathbf{x}^B_p)_k
undermat{k}{vertbar & & phantom{---}vertbarphantom{---}} & & undermat{k}{vertbar & & {phantom{---}vertbarphantom{---}}}
end{pmatrix}.
end{align}
% Update vertbar
renewcommand{vertbar}[2]{{%
setlength{fboxsep}{.5fboxsep}
ooalign{%
hidewidthrule[-1.5htstrutbox]{.4pt}{3.5htstrutbox}hidewidthcr%
colorbox{white}{$#2strut$}rule[-1.5htstrutbox]{0pt}{3.5htstrutbox}%
}
}}
% Measure some components of the construction
newlength{xpB}settowidth{xpB}{$mathbf{x}_p^B$}
newlength{NxaB}settowidth{NxaB}{$mathcal{N} bigl( mathbf{x}_p^B bigr)_1$}
newlength{NxpB}settowidth{NxpB}{$mathcal{N} bigl( mathbf{x}_p^B bigr)_k$}
Updated:
begin{align}
mathbf{W}_{BA} &
Biggl(
hspace{0.5xpB}
underbrace{
hspace{-0.5xpB}
vertbar{x1B}{mathbf{x}_1^B} hspace{0.5em} cdots hspace{0.5em} vertbar{x1B}{mathbf{x}_1^B}
hspace{-0.5xpB}
}_k
hspace{0.5xpB}
quad cdots quad
hspace{0.5xpB}
underbrace{
hspace{-0.5xpB}
vertbar{xpB}{mathbf{x}_p^B} hspace{0.5em} cdots hspace{0.5em} vertbar{xpB}{mathbf{x}_p^B}
hspace{-0.5xpB}
}_k
hspace{0.5xpB}
Biggr) = notag
& Biggl(
hspace{0.5NxaB}
underbrace{
hspace{-0.5NxaB}
vertbar{Nx1B}{mathcal{N} bigl( mathbf{x}_1^B bigr)_1} hspace{0.5em} cdots hspace{0.5em} vertbar{Nx1B}{mathcal{N} bigl( mathbf{x}_1^B bigr)_k}
hspace{-0.5NxaB}
}_k
hspace{0.5NxaB}
quad cdots quad
hspace{0.5NxpB}
underbrace{
hspace{-0.5NxpB}
vertbar{NxpB}{mathcal{N} bigl( mathbf{x}_p^B bigr)_1} hspace{0.5em} cdots hspace{0.5em} vertbar{NxpB}{mathcal{N} bigl( mathbf{x}_p^B bigr)_k}
hspace{-0.5NxpB}
}_k
hspace{0.5NxpB}
Biggr)
end{align}
end{document}
Correct answer by Werner on June 15, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP