Math & Sciencemulti-column matrix headings

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
maurolust
Posts: 13
Joined: Fri May 02, 2008 8:58 pm

multi-column matrix headings

Post by maurolust »

Hi,

I want to display a mock-up of a matrix while making it a clear distinction between the structure in the two parts of a matrix. I made an almost successful attempt, but it resulted in unmatching parenthesis sizes, in addition to other alignment problems.

The minimal working examples show tiny matrices where the problem is quite evident.

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\[
\begin{array}{r |c|c|}
    &  \mathbf{H^{\;(1)}_{m \times k}} &  \mathbf{H^{\;(2)}_{m \times k}}  \\
    {\bf H}_\textrm{IRA}= & 
        \left(\overbrace{
            \begin{array}{ccc}
                \text{{\scriptsize{1}}} &  &\text{{\scriptsize{1}}}\\
                \text{{\scriptsize{1}}} & \text{{\footnotesize{1}}} &\\
                \text{{\scriptsize{1}}}&  & \\
            \end{array} }
        \right.
        &
        \left.\overbrace{
            \begin{array}{ccc}
                \text{{\scriptsize{1}}} &  &\text{\Huge{0}}\\
                \text{{\scriptsize{1}}} & \text{{\scriptsize{1}}} &\\
                \text{\Huge{0}}&  \text{{\scriptsize{1}}} &\text{{\scriptsize{1}}}
            \end{array} }
        \right)
\end{array}
\]
\end{document}
I tried another approach that allowed me to match the parenthesis, but the vertical alignment issues persists and the labels are not centered above the submatrices. Any suggestions? I'm including a picture of the actual matrix I want to display, build using the first method. It looks ok, but I didn't like the unmatching parenthesis sizes.

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\[
\begin{array}{r |c|}
    &
    \begin{array}{|c|c|}
        \hfill\mathbf{H^{\;(1)}_{m \times k}}\hfill & \hfill\mathbf{H^{\;(2)}_{m \times k}}\hfill
    \end{array}\\

    {\bf H}_\textrm{IRA} = &
    \left(\begin{array}{c|c}
           \overbrace{\begin{array}{ccc}
                          \text{{\scriptsize{1}}} &  &\text{{\scriptsize{1}}}\\
                          \text{{\scriptsize{1}}} & \text{{\footnotesize{1}}} &\\
                          \text{{\scriptsize{1}}}&  & \\
                      \end{array} }
    &
           \overbrace{\begin{array}{ccc}
                        \text{{\scriptsize{1}}} &  &\text{\Huge{0}}\\
                        \text{{\scriptsize{1}}} & \text{{\scriptsize{1}}} &\\
                        \text{\Huge{0}}&  \text{{\scriptsize{1}}} &\text{{\scriptsize{1}}}
                      \end{array} }
          \end{array}\right)\\

\end{array}
\]
\end{document}
God bless you
Attachments
This is almost what I want, but there are the unmatching parentheses.
This is almost what I want, but there are the unmatching parentheses.
matriz_problema.PNG (7.18 KiB) Viewed 5081 times
LaTeX itself handles the presentation of the document, allowing the writer to concentrate on the \textbf{conten...
!Runaway argument?
\par
<inserted text>
... concentrate on the \textbf{content}}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

multi-column matrix headings

Post by php1ic »

Not sure if this is what you want, but I have tricked latex into aligning things by using white text.

Code: Select all

\documentclass{article}
\usepackage{amsmath,color}
\begin{document}
\[
\mathbf{H}_{\textrm{IRA}} =
\begin{matrix}
\mathbf{H^{(1)}_{m\times k}} & \mathbf{H^{(2)}_{m\times k}}\\
\left(\overbrace{\begin{matrix}1&\textrm{\Huge{{\color{white}{1}}}}&1\\1&1&\textrm{\Huge{{\color{white}{1}}}}\\1&&\textrm{\Huge{{\color{white}{1}}}}\end{matrix}}\right.
&
\left.\overbrace{\begin{matrix}1&&\textrm{\Huge{0}}\\1&1&\textrm{\Huge{{\color{white}{1}}}}\\\textrm{\Huge{0}}&1&1\end{matrix}}\right)
\end{matrix}
\]
\end{document}
as long as each row of the two sub matrices contains a big number then alignment seems to work.

EDIT: I can't work out exactly what you want from the picture, but will have a go if you tell me the values of m and k and the cells that contain a huge 0.
maurolust
Posts: 13
Joined: Fri May 02, 2008 8:58 pm

Re: multi-column matrix headings

Post by maurolust »

@ php1ic
Thank you very much.

I think your solution is very close to what I need, maybe the white text will leave some "evidence" (mouse over, text selection, etc) but the effect would be pretty much what I want: a nicely formatted matrix. Maybe there is an invisible text command?

The values of k and m are 6 and 6, I think. I just wanted to pass the impression that the right section has a staircase shape and the left section is sparse and doesn't follow any visible pattern.
LaTeX itself handles the presentation of the document, allowing the writer to concentrate on the \textbf{conten...
!Runaway argument?
\par
<inserted text>
... concentrate on the \textbf{content}}
php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

multi-column matrix headings

Post by php1ic »

I hadn't thought about what would happen with mouse over,

Code: Select all

\phantom{}
seems to be exactly what you want, it uses the space that would be needed, but doesn't print anything. This piece of code produces the matrix that was in your first post.

Code: Select all

\[
\mathbf{H}_{\textrm{IRA}} =
\begin{matrix}
\mathbf{H^{(1)}_{m\times k}}&\mathbf{H^{(2)}_{m\times k}}\\
\left(
\overbrace{\begin{matrix}
1&\phantom{\textrm{\Huge{0}}}&&1&&\\
&&\textrm{\Huge{0}}&&1&\textrm{\Huge{0}}\\
\textrm{\Huge{0}}&&1&&&1\\
1&&&&\textrm{\Huge{0}}&\\
&&\textrm{\Huge{0}}&&&1\\
&1&\phantom{\textrm{\Huge{0}}}&&1&
\end{matrix}}
\right.
&
\left.\overbrace{\begin{matrix}
1&&&&&\phantom{\textrm{\Huge{0}}}\\
1&1&&&\textrm{\Huge{0}}&\\
&1&\ddots&&&\phantom{\textrm{\Huge{0}}}\\
&&\ddots&1&&\phantom{\textrm{\Huge{0}}}\\
&\textrm{\Huge{0}}&&1&1&\\
\phantom{\textrm{\Huge{0}}}&&&&1&1
\end{matrix}}\right)
\end{matrix}
\]
Post Reply