Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have two related tables that could naturally be displayed side-by-side but don't have to be. However, it saves space to display them side-by-side rather than one atop the other. If I do so without tweaking the alignment, it looks ugly:

\begin{center}
    \(
        \begin{array}{l|cccccc}
            &   A   &   B   &   C   &   D   &   E   &   F   \\ \hline
        x^A &   1   &   3   &   1   &   1   &   1   &   2   \\
        x^B &   2   &   2   &   2   &   0   &   2   &   0   \\
        x^C &   3   &   1   &   3   &   1   &   0   &   1
        \end{array}
    \)
    \hspace{.5in}
    \(
        \begin{array}{l|cccc}
                    &   x           &   y       &   z   &   w   \\ \hline
            q=1     &   1           &   0       &   0   &   1   \\
            q\neq 1 &   0           &   1       &   1   &   1   \\
        \end{array}
    \)
\end{center}

MWE Displayed

Therefore, right now I am using the following hack to make the rows line up.

\begin{center}
    \(
        \begin{array}{l|cccccc}
            &   A   &   B   &   C   &   D   &   E   &   F   \\ \hline
        x^A &   1   &   3   &   1   &   1   &   1   &   2   \\
        x^B &   2   &   2   &   2   &   0   &   2   &   0   \\
        x^C &   3   &   1   &   3   &   1   &   0   &   1
        \end{array}
    \)
    \hspace{.5in}
    \(
        \begin{array}{l|cccc}
                    &   x           &   y       &   z   &   w   \\ \hline
            q=1     &   1           &   0       &   0   &   1   \\
            q\neq 1 &   0           &   1       &   1   &   1   \\
            \multicolumn{2}{c}{ }   &           &       &
        \end{array}
    \)
\end{center}

Is this bad practice? If so, what is the right way to do it?

If the answer is "two tables that need to be side-by-side are two tables that need to be one table"--and therefore that these two tables should not be side-by-side--so be it.

share|improve this question
1  
I would use a regular display math environment (like \[...\]) and top-aligned arrays: \begin{array}[t]{...}. –  Werner Aug 15 '12 at 23:13
    
Thanks! I never knew there was an [alignment] option for the array env. That certainly works to produce the second result without as bad a hack. Maybe add as answer and I'll accept if nothing even better comes along :) –  Philip Aug 15 '12 at 23:16

1 Answer 1

up vote 10 down vote accepted

Since the contents is a display of math content, I'd suggest a display math environment with some fixed-width separation (like \qquad). Also align the arrays at the top:

enter image description here

\documentclass{article}
\begin{document}
I have two related tables that could naturally be displayed side-by-side but don't have to be. 
However, it saves space to display them side-by-side rather than one atop the other. If I do so 
without tweaking the alignment, it looks ugly:
\begin{center}
    \(
        \begin{array}{l|cccccc}
            &   A   &   B   &   C   &   D   &   E   &   F   \\ \hline
        x^A &   1   &   3   &   1   &   1   &   1   &   2   \\
        x^B &   2   &   2   &   2   &   0   &   2   &   0   \\
        x^C &   3   &   1   &   3   &   1   &   0   &   1
        \end{array}
    \)
    \hspace{.5in}
    \(
        \begin{array}{l|cccc}
                    &   x           &   y       &   z   &   w   \\ \hline
            q=1     &   1           &   0       &   0   &   1   \\
            q\neq 1 &   0           &   1       &   1   &   1   \\
        \end{array}
    \)
\end{center}
The following is a little cleaner:
\[
  \renewcommand{\arraystretch}{1.2}
  \begin{array}[t]{l|cccccc}
            &   A   &   B   &   C   &   D   &   E   &   F   \\ \hline
        x^A &   1   &   3   &   1   &   1   &   1   &   2   \\
        x^B &   2   &   2   &   2   &   0   &   2   &   0   \\
        x^C &   3   &   1   &   3   &   1   &   0   &   1
  \end{array}
  \qquad
  \begin{array}[t]{l|cccc}
                    &   x           &   y       &   z   &   w   \\ \hline
            q=1     &   1           &   0       &   0   &   1   \\
            q\neq 1 &   0           &   1       &   1   &   1
  \end{array}
\]
\end{document}​

This will ensure a consistent spacing with other display math content. Also, using a larger \arraystretch sometimes help with superscripts/subscripts running into other rows.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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