3

I am trying to make the right brace cover the whole matrix like the `\overbrace'. Is there a way to do this?

\documentclass[reqno,12pt]{amsart}
\usepackage{amsmath,mathtools,amssymb}
\usepackage[top=2cm,left=2cm,right=2cm]{geometry}
\author{something}
\title{something}

\begin{document}
\maketitle
\section{something}
 \begin{equation}
    \mathbf{G}=\overbrace{\begin{bmatrix}
    0&0&0&0&0\\
    0&0&0&0&0\\
    0.271&0&0&0&0\\
    0.498&0.271&0&0&0\\
    0.687&0.498&0.271&0&0\\
    0.845&0.687&0.498&0.271&0\\
    0.977&0.845&0.687&0.498&0.271\\
    1.087&0.977&0.845&0.687&0.498\\
    1.179&1.087&0.977&0.845&0.687\\
    1.256&1.179&1.087&0.977&0.845
    \end{bmatrix}}^{\text{something 1}} \Biggr\rbrace
  \text{something 2}
 \end{equation}
\end{document}

enter image description here

Something that works like \right\rbrace. Unfortunately you can't use \right alone. There is a workaround here tex.stackexchange.com/q/130798/156344. I would appreciate it if someone could tell me how to translate the TeX to LateX used there.

  • 1
    \left. \right\}? – JouleV Apr 22 at 15:30
  • I just need the right brace. Not the left one – Al_Fh Apr 22 at 15:33
  • 1
    Yes. \left. doesn't produce anything. However, honestly this way is very bad. Consider something like tex.stackexchange.com/q/130798/156344 – JouleV Apr 22 at 15:34
  • 1
    It is not so ugly if you use \left \right a bit more carefully. The problem is the horizontal brace. – JouleV Apr 22 at 15:38
  • 1
    The TeX commands are very different. Actually TeX is far harder. Those command are just advanced LaTeX commands – JouleV Apr 23 at 4:04
4

Writing in your style:

\documentclass[reqno,12pt]{amsart}
\usepackage{amsmath,mathtools,amssymb}
\usepackage[top=2cm,left=2cm,right=2cm]{geometry}
\author{something}
\title{something}
\begin{document}
\maketitle
\section{something}
 \begin{equation}
 \newcommand\yourmatrix{\begin{bmatrix}
    0&0&0&0&0\\
    0&0&0&0&0\\
    0.271&0&0&0&0\\
    0.498&0.271&0&0&0\\
    0.687&0.498&0.271&0&0\\
    0.845&0.687&0.498&0.271&0\\
    0.977&0.845&0.687&0.498&0.271\\
    1.087&0.977&0.845&0.687&0.498\\
    1.179&1.087&0.977&0.845&0.687\\
    1.256&1.179&1.087&0.977&0.845
\end{bmatrix}}
    \mathbf{G}=\overbrace{\yourmatrix}^{\text{something 1}}\left.\vphantom{\yourmatrix}\right\}{\scriptstyle\text{something 2}}
 \end{equation}
\end{document}

In this way, the vertical brace is good, but it is a little painful to have it. The horizontal brace is not good because it groups the whole matrix (with brackets). Consider some methods used in braces over matrix and similar questions.

enter image description here


This is a good modification of it, but this is a bit overkill. Literally you can't avoid defining a macro if you follow this way.

\documentclass[varwidth]{standalone}
\usepackage{amsmath,mathtools,amssymb}
\begin{document}
 \begin{equation}
 \newcommand\yourmatrix{\begin{matrix}
    0&0&0&0&0\\
    0&0&0&0&0\\
    0.271&0&0&0&0\\
    0.498&0.271&0&0&0\\
    0.687&0.498&0.271&0&0\\
    0.845&0.687&0.498&0.271&0\\
    0.977&0.845&0.687&0.498&0.271\\
    1.087&0.977&0.845&0.687&0.498\\
    1.179&1.087&0.977&0.845&0.687\\
    1.256&1.179&1.087&0.977&0.845
\end{matrix}}
    \mathbf{G}=\left[\vphantom{\yourmatrix}\right.\overbrace{\yourmatrix}^{\text{something 1}}\left.\vphantom{\yourmatrix}\right]\left.\vphantom{\yourmatrix}\right\}{\scriptstyle\text{something 2}}
 \end{equation}
\end{document}

enter image description here


Using savebox (hope I get it right – please correct me if not)

\documentclass[varwidth]{standalone}
\usepackage{amsmath,mathtools,amssymb}
\newsavebox{\yourmatrix}
\begin{document}
 \begin{equation}
 \sbox{\yourmatrix}{$\begin{matrix}
    0&0&0&0&0\\
    0&0&0&0&0\\
    0.271&0&0&0&0\\
    0.498&0.271&0&0&0\\
    0.687&0.498&0.271&0&0\\
    0.845&0.687&0.498&0.271&0\\
    0.977&0.845&0.687&0.498&0.271\\
    1.087&0.977&0.845&0.687&0.498\\
    1.179&1.087&0.977&0.845&0.687\\
    1.256&1.179&1.087&0.977&0.845
\end{matrix}$}
    \mathbf{G}=\left[\vphantom{\usebox{\yourmatrix}}\right.\overbrace{\usebox{\yourmatrix}}^{\text{something 1}}\left.\vphantom{\usebox{\yourmatrix}}\right]\left.\vphantom{\usebox{\yourmatrix}}\right\}{\scriptstyle\text{something 2}}
 \end{equation}
\end{document}

(same output as above)

  • 2
    You could make \yourmatrix a savebox instead of a macro. – John Kormylo Apr 22 at 15:46
  • @JohnKormylo Actually I read the linked question even before my attempts to answer this one. Both answers there use macros, so I am inspired :)) – JouleV Apr 22 at 15:48
  • 3
    I'd set the definition of \yourmatrix insde the equation environment itself, so it's local to the environment and not far from its usage. Having it in the preamble makes changes more awkward. This is even more necessary if you use the \sbox strategy, because math fonts might get chosen at begin document. – egreg Apr 22 at 15:54
  • @egreg Yes, you are right. Localization is needed in this case, or we will need to define a hundred of different \yourmatrixs - maybe running out of name. – JouleV Apr 22 at 15:57
4

Saveboxes are basically pre-formatted text, and are therefore faster than expanding a macro. More to the point, one can extract the width, height and depth directly.

\documentclass[varwidth]{standalone}
\usepackage{amsmath,mathtools,amssymb}
\newsavebox{\yourmatrix}
\savebox{\yourmatrix}{$\begin{matrix}
    0&0&0&0&0\\
    0&0&0&0&0\\
    0.271&0&0&0&0\\
    0.498&0.271&0&0&0\\
    0.687&0.498&0.271&0&0\\
    0.845&0.687&0.498&0.271&0\\
    0.977&0.845&0.687&0.498&0.271\\
    1.087&0.977&0.845&0.687&0.498\\
    1.179&1.087&0.977&0.845&0.687\\
    1.256&1.179&1.087&0.977&0.845
\end{matrix}$}
\newcommand{\vphantombox}[1]{\vrule width0pt height\ht#1 depth\dp#1}
\begin{document}
 \begin{equation}
    \mathbf{G}=\left[\vphantombox\yourmatrix\right.\overbrace{\usebox\yourmatrix}^{\text{something 1}}\left.\vphantombox\yourmatrix\right]\left.\vphantombox\yourmatrix\right\}{\scriptstyle\text{something 2}}
 \end{equation}
\end{document}
  • Is it necessary to declare the \newsavebox in the preamble? – Al_Fh Apr 22 at 16:14
  • 2
    \newsavebox should be in the preamble, but \savebox usually isn't. – John Kormylo Apr 22 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.