2

I need to write a matrix with decorations, and I decided to use arrays in an array. I seem to be able to "almost" achieve what I wanted, but there is a couple of questions I would like to ask.

Here is an example and code. There are 4 sub-arrays in an array.

enter image description here

Q1 The first two columns and the last two columns are aligned well, but I do not know how to make all of them aligned vertically.

I tried to put overbrace/underbace for the first two, but it did not help.

Q2 Is there a way to make the separator starting/ending from the first row and the last row, not from the starting and ending point of overbrace/underbrace?

I tried to play with Bigl and Bigr, but I did not succeed.

\documentclass{amsart}
\usepackage{amsmath}

\begin{document}

\begin{equation}
\begin{array}{c|c|cc}
\begin{array}{c}
x
\end{array}
&
\overbrace{
\left[ 
\begin{array}{c}
* 
\end{array} \right.
}^{f}
&
\overbrace{
\begin{array}{c|c}
\underbrace{
\begin{array}{c}
* 
\end{array}
}_{xx~terms}
&
\left.
\begin{array}{cccc}
0 
\end{array}
\right]
\end{array}
}^{g}
\end{array}
\end{equation} 
\end{document}

I also tried \def\arraystretch{2}, but it did not help.

6
  • Can you draw a picture? I'm not clear what you mean in Q2.
    – Sandy G
    Commented Dec 19, 2017 at 2:52
  • What about this?
    – Werner
    Commented Dec 19, 2017 at 3:30
  • @Werner That is very neat. Is it different to Sandy's answer below? If so, I'm interested in seeing your code.
    – Youngsu
    Commented Dec 19, 2017 at 4:35
  • Use Sandy's code, swap amsmath for mathtools and use \mathclap{\text{$xx$ terms}}.
    – Werner
    Commented Dec 19, 2017 at 4:53
  • 1
    @Youngsu: the $xx$ terms text unnecessarily pushes out the content represented by * since its wider than the \underbrace itself. \mathclap removes any horizontal width from the $xx$ terms description. It's not necessary, but perhaps is aesthetically more pleasing.
    – Werner
    Commented Dec 19, 2017 at 6:36

1 Answer 1

7

Is this what you mean?

enter image description here

You don't need an array. Just one line of math with over- and under-braces.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\[
x|\overbrace{[\;*\;}^f|\overbrace{\underbrace{*}_{xx\text{ terms}}\mid\;0\;]}^g
\]
\end{document}

It now occurs to me that you may want the overbraces to be inside the delimiters. And I think you want the * terms to be potentially bigger (vertically) as in the following:

enter image description here

The code is more complicated, but all the delimiters will adjust in size. I made a macro for the 3x1 matrix called \vertm just to simplify a bit. Then there is a second macro called \vphnm that is just the first matrix enclosed in a \vphantom command. This is necessary to have the delimiters adjust to the matrix and not to the over and under braces.

Note Werner's suggestion to use mathtools and \mathclap.

Here is the code:

\documentclass{article}
\usepackage{mathtools}

\newcommand{\vertm}{\begin{pmatrix}1\\2\\3\end{pmatrix}}
\newcommand{\vphnm}{\vphantom{\vertm}}

\begin{document}
\[
x\left|\vphnm\right[\!\overbrace{\vertm}^f\left|\vphnm\right.%
    \overbrace{\underbrace{\vertm}_{\mathclap{\text{$xx$ terms}}}%
    \left|\vphnm\;0\right.}^g\left.\vphnm\!\right]
\]

\end{document}
5
  • Thanks for your answer. I have one more question. The entries I have are vertical matrices. So \mid does not extend all the way up and down. Is there a command which does the job? I was thinking of using something like array{:c} (in my work I need : instead of | in the example) in between, but I'd prefer using something that is compact.
    – Youngsu
    Commented Dec 19, 2017 at 4:29
  • Which entries are the vertical matrices? Does \Big| do the job? Do you also want the brackets to adjust in size?
    – Sandy G
    Commented Dec 19, 2017 at 4:48
  • I do not believe that \Big| extends arbitrary in size. Yes, I want the brackets to adjust in size.
    – Youngsu
    Commented Dec 19, 2017 at 5:07
  • Please see my updated response. Is that what you had in mind?
    – Sandy G
    Commented Dec 19, 2017 at 5:33
  • It looks very good. The only question I have is if one can replace \left| by something like \left: to have a long enough :. But I believe this can be a separate question. Thank you again for your help!
    – Youngsu
    Commented Dec 19, 2017 at 5:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .