1

I want to draw three tables next to each-other horizontally.

EDIT: In response to comment have dropped the minipage.

\centering seems to stack them on top of each other, is there a way to force a single line?

Code here & screenshot below:

\documentclass{article}
\usepackage{array}

\begin{document}

    \centering
    \setlength{\extrarowheight}{3pt}
        \begin{tabular}[t]{c|c|c|c|}
            \multicolumn{1}{c}{} & \multicolumn{1}{c}{$AA$}  & \multicolumn{1}{c}{$AB$}  & \multicolumn{1}{c}{$BB$} \\\cline{2-4}
            $AA$ & $P_{11}^{AA}$ & $P_{12}^{AA}$ & $P_{13}^{AA}$ \\\cline{2-4}
            $AB$ & $P_{21}^{AA}$ & $P_{22}^{AA}$ & $P_{23}^{AA}$ \\\cline{2-4}
            $BB$ & $P_{31}^{AA}$ & $P_{32}^{AA}$ & $P_{33}^{AA}$ \\\cline{2-4}
        \end{tabular}
        \begin{tabular}[t]{c|c|c|c|}
            \multicolumn{1}{c}{} & \multicolumn{1}{c}{$AA$}  & \multicolumn{1}{c}{$AB$}  & \multicolumn{1}{c}{$BB$} \\\cline{2-4}
            $AA$ & $P_{11}^{AB}$ & $P_{12}^{AB}$ & $P_{13}^{AB}$ \\\cline{2-4}
            $AB$ & $P_{21}^{AB}$ & $P_{22}^{AB}$ & $P_{23}^{AB}$ \\\cline{2-4}
            $BB$ & $P_{31}^{AB}$ & $P_{32}^{AB}$ & $P_{33}^{AB}$ \\\cline{2-4}
        \end{tabular}
        \begin{tabular}[t]{c|c|c|c|}
            \multicolumn{1}{c}{} & \multicolumn{1}{c}{$AA$}  & \multicolumn{1}{c}{$AB$}  & \multicolumn{1}{c}{$BB$} \\\cline{2-4}
            $AA$ & $P_{11}^{BB}$ & $P_{12}^{BB}$ & $P_{13}^{BB}$ \\\cline{2-4}
            $AB$ & $P_{21}^{BB}$ & $P_{22}^{BB}$ & $P_{23}^{BB}$ \\\cline{2-4}
            $BB$ & $P_{31}^{BB}$ & $P_{32}^{BB}$ & $P_{33}^{BB}$ \\\cline{2-4}
        \end{tabular}

\end{document}

enter image description here

  • 1
    it's a normal paragraph indent so you could use \noindent or wrap in a center environment etc also you don't need the minipages, you could just use three tabular – David Carlisle Feb 5 at 11:03
  • Thanks for the tips! Have edited the post to drop minipages. \centering seems to stack them, is there a way to force a single line? I also tried \noindent but it only seemed to move them left by a very small amount. – user3234810 Feb 5 at 11:22
  • 2
    they are placed like letters you have one word space between each tabular (from the newline) and they do not fit on a line so just as if you have one two three it line breaks at the second space if needed. you could use \small – David Carlisle Feb 5 at 11:32
1

If you can't increase the width of the text block, some of the following, not mutually exclusive, measures may yield success:

  • Switch from a tabular environment to an array environment. The default amount of intercolumn whitespace is smaller for array environments is smaller than that for tabular environments. Plus, making this switch would let you get rid of ninety [90!] $ symbols.

  • Reduce the amount of intercolumn whitespace, which is governed by the \tabcolsep and \arraycolsep macros. Their default values are 6pt and 5pt, respectively, in many document classes.

  • Change \begin{array}[t]{c|c|c|c|} to \begin{array}[t]{@{}c|c|c|c|}, to lop off \arraycolsep whitespace.

  • Switch to a smaller font size. The \small and \footnotesize directives bring about 10% and 20% linear font size reductions, respectively.

The following screenshot and minimum working example shows the combined effect of implementing all four of these ideas.

enter image description here

\documentclass{article}
\usepackage{array}
\setlength{\extrarowheight}{3pt}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}

\begin{center}
\small
\setlength\arraycolsep{3pt} % default value: 5pt
$\begin{array}[t]{@{}c|c|c|c|}
    \mc{} & \mc{AA}  & \mc{AB}  & \mc{BB} \\
    \cline{2-4}
    AA & P_{11}^{AA} & P_{12}^{AA} & P_{13}^{AA} \\\cline{2-4}
    AB & P_{21}^{AA} & P_{22}^{AA} & P_{23}^{AA} \\\cline{2-4}
    BB & P_{31}^{AA} & P_{32}^{AA} & P_{33}^{AA} \\\cline{2-4}
\end{array}$\hfill
$\begin{array}[t]{@{}c|c|c|c|}
    \mc{} & \mc{AA}  & \mc{AB}  & \mc{BB} \\
    \cline{2-4}
    AA & P_{11}^{AB} & P_{12}^{AB} & P_{13}^{AB} \\\cline{2-4}
    AB & P_{21}^{AB} & P_{22}^{AB} & P_{23}^{AB} \\\cline{2-4}
    BB & P_{31}^{AB} & P_{32}^{AB} & P_{33}^{AB} \\\cline{2-4}
\end{array}$\hfill
$\begin{array}[t]{@{}c|c|c|c|}
    \mc{} & \mc{AA}  & \mc{AB}  & \mc{BB} \\
    \cline{2-4}
    AA & P_{11}^{BB} & P_{12}^{BB} & P_{13}^{BB} \\\cline{2-4}
    AB & P_{21}^{BB} & P_{22}^{BB} & P_{23}^{BB} \\\cline{2-4}
    BB & P_{31}^{BB} & P_{32}^{BB} & P_{33}^{BB} \\\cline{2-4}
\end{array}$
\end{center}
\end{document}
| improve this answer | |
  • 1
    This worked perfectly - I greatly appreciate the additional explanations. This is my first TeX project. – user3234810 Feb 5 at 14:43
  • 1
    @user3234710 - you’re most welcome – Mico Feb 5 at 15:32

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.