2

Oftentimes the best way I can figure out how to lay out something is with the mindset I learned from HTML, tables within tables. How can I modify parameters affecting the external table without affecting the internal tables?

For example, suppose I want to do the MWE below.

\documentclass{article}
\usepackage[left=0.50in, right=0.50in, top=0.50in, bottom=0.5in]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tabularx}

\begin{document}

\begin{tabularx}{\textwidth}{lXX}
    Short Title &
    Longer sentence giving a description of the thing to the right. &
    \({
    \begin{bmatrix}
        a & a & a & a \\
        a & a & a & a \\
        a & a & a & a \\
        a & a & a & a
    \end{bmatrix}
    \begin{bmatrix}
        b & b & b & b \\
        b & b & b & b \\
        b & b & b & b \\
        b & b & b & b
    \end{bmatrix}
    =
    \begin{bmatrix}
        c & c & c & c \\
        c & c & c & c \\
        c & c & c & c \\
        c & c & c & c
    \end{bmatrix}
    }\) \\
    Another line &
    That is like the one above. &
    \({
    \begin{bmatrix}
        a & a & a & a \\
        a & a & a & a \\
        a & a & a & a \\
        a & a & a & a
    \end{bmatrix}
    \begin{bmatrix}
        b & b & b & b \\
        b & b & b & b \\
        b & b & b & b \\
        b & b & b & b
    \end{bmatrix}
    =
    \begin{bmatrix}
        c & c & c & c \\
        c & c & c & c \\
        c & c & c & c \\
        c & c & c & c
    \end{bmatrix}
    }\)
\end{tabularx}

\end{document}

enter image description here

Clearly I want more space between the rows and columns of the outer table, without affecting the inner ones (which sometimes are tabular instead of bmatrix). Sometimes I want to tweak all the inner tables without affecting the outer one.

Is there a clean way to do this, without peppering commands all throughout? Like, is there a CSS style method where I could define a table class and then specify that the outer table is of some class different than the regular ones?


Update

Here's another example. Using egreg's answer below, I have to put in 2(r-1) instances of \addlinespace, and it interrupts the vertical lines.

\documentclass[12pt]{article}
\usepackage[landscape]{geometry}
\usepackage{amsmath}
\usepackage{booktabs}

\begin{document}


\begin{alignat*}{4}
    &
    \left[
    \begin{array}{c|c}
        \begin{bmatrix}
            a & b
        \end{bmatrix}
        \begin{bmatrix}
            w \\ y
        \end{bmatrix}
        &
        \begin{bmatrix}
            a & b
        \end{bmatrix}
        \begin{bmatrix}
            x \\ z
        \end{bmatrix}
        \\ \hline
        \begin{bmatrix}
            c & d
        \end{bmatrix}
        \begin{bmatrix}
            w \\ y
        \end{bmatrix}
        &
        \begin{bmatrix}
            c & d
        \end{bmatrix}
        \begin{bmatrix}
            x \\ z
        \end{bmatrix}
        \\ \hline
        \begin{bmatrix}
            e & f
        \end{bmatrix}
        \begin{bmatrix}
            w \\ y
        \end{bmatrix}
        &
        \begin{bmatrix}
            e & f
        \end{bmatrix}
        \begin{bmatrix}
            x \\ z
        \end{bmatrix}
    \end{array}
    \right]
    &&
    \renewcommand\arraystretch{1.2}
    \left[
    \begin{array}{c|c}
        \begin{bmatrix}
            a & b
        \end{bmatrix}
        \begin{bmatrix}
            w \\ y
        \end{bmatrix}
        &
        \begin{bmatrix}
            a & b
        \end{bmatrix}
        \begin{bmatrix}
            x \\ z
        \end{bmatrix}
        \\ \hline
        \begin{bmatrix}
            c & d
        \end{bmatrix}
        \begin{bmatrix}
            w \\ y
        \end{bmatrix}
        &
        \begin{bmatrix}
            c & d
        \end{bmatrix}
        \begin{bmatrix}
            x \\ z
        \end{bmatrix}
        \\ \hline
        \begin{bmatrix}
            e & f
        \end{bmatrix}
        \begin{bmatrix}
            w \\ y
        \end{bmatrix}
        &
        \begin{bmatrix}
            e & f
        \end{bmatrix}
        \begin{bmatrix}
            x \\ z
        \end{bmatrix}
    \end{array}
    \right]
    &&
    \renewcommand\arraystretch{1}
    \left[
    \begin{array}{c|c}
        \begin{bmatrix}
            a & b
        \end{bmatrix}
        \begin{bmatrix}
            w \\ y
        \end{bmatrix}
        &
        \begin{bmatrix}
            a & b
        \end{bmatrix}
        \begin{bmatrix}
            x \\ z
        \end{bmatrix}
        \\ \addlinespace \hline \addlinespace
        \begin{bmatrix}
            c & d
        \end{bmatrix}
        \begin{bmatrix}
            w \\ y
        \end{bmatrix}
        &
        \begin{bmatrix}
            c & d
        \end{bmatrix}
        \begin{bmatrix}
            x \\ z
        \end{bmatrix}
        \\ \addlinespace \hline \addlinespace
        \begin{bmatrix}
            e & f
        \end{bmatrix}
        \begin{bmatrix}
            w \\ y
        \end{bmatrix}
        &
        \begin{bmatrix}
            e & f
        \end{bmatrix}
        \begin{bmatrix}
            x \\ z
        \end{bmatrix}
    \end{array}
    \right]
    &&
    \left[
    \begin{array}{c|c}
        \begin{bmatrix}
            a & b
        \end{bmatrix}
        \begin{bmatrix}
            w \\ y
        \end{bmatrix}
        &
        \begin{bmatrix}
            a & b
        \end{bmatrix}
        \begin{bmatrix}
            x \\ z
        \end{bmatrix}
        \\[12pt] \hline
        \begin{bmatrix}
            c & d
        \end{bmatrix}
        \begin{bmatrix}
            w \\ y
        \end{bmatrix}
        &
        \begin{bmatrix}
            c & d
        \end{bmatrix}
        \begin{bmatrix}
            x \\ z
        \end{bmatrix}
        \\[12pt] \hline \\[12pt]
        \begin{bmatrix}
            e & f
        \end{bmatrix}
        \begin{bmatrix}
            w \\ y
        \end{bmatrix}
        &
        \begin{bmatrix}
            e & f
        \end{bmatrix}
        \begin{bmatrix}
            x \\ z
        \end{bmatrix}
    \end{array}
    \right]
    \\
    &\text{No changes.}&
    &
    \begin{array}{l}
        \text{\textbackslash arraystretch} \\ \text{changes everything}
    \end{array}
    &
    &\text{Using \textbackslash addlinespace.}&
    &\begin{array}{l}
            \text{Nope.} \\ \text{and O.M.G.!!}
    \end{array}
\end{alignat*}

\end{document}

enter image description here

I just want to be able to do something like (pseudocode):

define OuterRowAndColSpacing

\begin{OuterArrayOrTable}[OuterRowAndColSpacing]
    \begin{InnerMatrix}
        ...
    \end{InnerMatrix}
    ...
\end{OuterArrayOrTable}

and have everything just work.

(Today is one of those of those days when I'm just like: You're getting a Word document, and you're going to accept it, and you're going to like it!)

  • Changes made inside a "group" are local to the group. {...} is a group. You would need at least one custom macro to specify all the parameters (\arraystretch, \arraycolsep, \baselineskip) for each group. – John Kormylo Oct 14 '16 at 14:45
  • @JohnKormylo I've tried this route, but the problem is that the inner tables are also inside the group that the outer table is in, so changes to the outer table also affect the inner ones. – Travis Bemrose Oct 14 '16 at 22:47
  • I think it's better if you comment @egreg's answer to draw his attention or ask a new question with reference to the old one, rather than edit it. I don't think many people read the edit of an already-answered question. – CarLaTeX Oct 22 '16 at 7:37
2

Explicitly set the intercolumn space:

\documentclass{article}
\usepackage[left=0.50in, right=0.50in, top=0.50in, bottom=0.5in]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tabularx,booktabs}

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{
  @{}% no left padding
  l
  @{\hspace{2cm}}% more padding (exaggerated)
  X
  @{\qquad}% more padding
  X
  @{}% no right padding
}
    Short Title &
    Longer sentence giving a description of the thing to the right. &
    \(
    \begin{bmatrix}
        a & a & a & a \\
        a & a & a & a \\
        a & a & a & a \\
        a & a & a & a
    \end{bmatrix}
    \begin{bmatrix}
        b & b & b & b \\
        b & b & b & b \\
        b & b & b & b \\
        b & b & b & b
    \end{bmatrix}
    =
    \begin{bmatrix}
        c & c & c & c \\
        c & c & c & c \\
        c & c & c & c \\
        c & c & c & c
    \end{bmatrix}
    \) \\
\addlinespace
    Another line &
    That is like the one above. &
    \(
    \begin{bmatrix}
        a & a & a & a \\
        a & a & a & a \\
        a & a & a & a \\
        a & a & a & a
    \end{bmatrix}
    \begin{bmatrix}
        b & b & b & b \\
        b & b & b & b \\
        b & b & b & b \\
        b & b & b & b
    \end{bmatrix}
    =
    \begin{bmatrix}
        c & c & c & c \\
        c & c & c & c \\
        c & c & c & c \\
        c & c & c & c
    \end{bmatrix}
    \)
\end{tabularx}

\end{document}

I used \addlinespace of booktabs for getting a better separation between rows.

enter image description here

| improve this answer | |
  • It's nice that the column stuff is centralized (all together), but is there a way to handle row spacing without having to pepper \addlinespace all through the table? I wish I knew more about these column specifications, but I haven't found a good resource. And it looks like the @{} just goes between the columns anyway, so I couldn't define custom column types. – Travis Bemrose Oct 14 '16 at 22:46
  • @TravisBemrose Sorry, but I don't understand what you mean about custom column types. The problem of touching rows is due to the extremely big matrices. Instead of \addlinespace you could fix it with \\[<dimen>, but it takes guessing the right value. – egreg Oct 14 '16 at 22:58
  • egreg, Please see my edit to the question above. I finally worked out that \\[12pt] \hline \\[-10pt] is about the only thing that gives the intended result, but I have to put this in between every row. Do you know of a way where I can simply use \\ in both my outer and inner tables/matrices, and just by changing some global line, the row spacing in the outer table/matrix changes, but not the inner ones? – Travis Bemrose Oct 24 '16 at 21:27
  • @TravisBemrose The edit shows a problem quite different from the one in the initial question. Please, revert and make a followup question. – egreg Oct 24 '16 at 21:44
  • Different? I'm arranging tables within tables, and want to easily alter the spacing of the outer ones without altering the inner ones. – Travis Bemrose Oct 29 '16 at 14:48

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.