[Tex/LaTex] minipage with tables

minipagetables

If I have a minipage like the following:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}

\begin{document}

\begin{minipage}{1\linewidth}
\centering
A
\medskip
B
\end{minipage}

\end{document}

Why it is not possible to insert tables instead of A and B? If I try, I get "LaTeX Error: Not in outer par mode."

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}

\begin{document}

\begin{minipage}{1\linewidth}
\centering
            \begin{table}[h]
                \centering
                \bgroup
                \def\arraystretch{1.2}
                \begin{tabular}{ c c | c | c | }
                    & & \multicolumn{2}{c|}{P2} \\
                    & & $a_1$ & $a_2$ \\
                    \hline
                    \multirow{2}{*}{P1} & $a_1$ & 0, 0 & 0, 0 \\
                    & $a_2$ & 0, 0 & 0, 0 \\
                    \hline
                \end{tabular}
                \egroup
                \caption{Title}
            \end{table}
\medskip
            \begin{table}[h]
                \centering
                \bgroup
                \def\arraystretch{1.2}
                \begin{tabular}{ c c | c | c | }
                    & & \multicolumn{2}{c|}{P2} \\
                    & & $a_1$ & $a_2$ \\
                    \hline
                    \multirow{2}{*}{P1} & $a_1$ & 0, 0 & 0, 0 \\
                    & $a_2$ & 0, 0 & 0, 0 \\
                    \hline
                \end{tabular}
                \egroup
                \caption{Title}
            \end{table}
\end{minipage}

\end{document}

Ideally, I would like to understand the meaning of "LaTeX Error: Not in outer par mode."

Best Answer

A table environment cannot be part of a minipage. Use only one environment table and no minipage! Such an environment can have more than one caption:

\documentclass{article}
\usepackage{multirow}

\begin{document}

\begin{table}
\centering
\def\arraystretch{1.2}
\begin{tabular}{ c c | c | c | }
    & & \multicolumn{2}{c|}{P2} \\
    & & $a_1$ & $a_2$ \\    \hline
 \multirow{2}{*}{P1} & $a_1$ & 0, 0 & 0, 0 \\
& $a_2$ & 0, 0 & 0, 0 \\\hline
\end{tabular}
\caption{Title}

\bigskip
\begin{tabular}{ c c | c | c | }
                & & \multicolumn{2}{c|}{P2} \\
                & & $a_1$ & $a_2$ \\
                \hline
                \multirow{2}{*}{P1} & $a_1$ & 0, 0 & 0, 0 \\
                & $a_2$ & 0, 0 & 0, 0 \\
                \hline
\end{tabular}
\caption{Title}
\end{table}

\end{document}

enter image description here

fro two tabulars side by side use:

\begin{table}
\centering
\def\arraystretch{1.2}
\begin{minipage}{0.48\linewidth}\centering
\begin{tabular}{ c c | c | c | }
    & & \multicolumn{2}{c|}{P2} \\
    & & $a_1$ & $a_2$ \\    \hline
 \multirow{2}{*}{P1} & $a_1$ & 0, 0 & 0, 0 \\
& $a_2$ & 0, 0 & 0, 0 \\\hline
\end{tabular}
\caption{Title}
\end{minipage}
%
\begin{minipage}{0.48\linewidth}\centering
\begin{tabular}{ c c | c | c | }
                & & \multicolumn{2}{c|}{P2} \\
                & & $a_1$ & $a_2$ \\
                \hline
                \multirow{2}{*}{P1} & $a_1$ & 0, 0 & 0, 0 \\
                & $a_2$ & 0, 0 & 0, 0 \\
                \hline
\end{tabular}
\caption{Title}
\end{minipage}
\end{table}

enter image description here

Related Question