1

I am trying to create 4 tables as below: However I would like to add a title to each tabular and a caption below each tabular.

If you have any suggestion on how I can proceed it would be great.

\begin{table}
    \centering

    \begin{tabular}{@{}cc|cc@{}}

    \multicolumn{1}{c}{} &\multicolumn{1}{c}{} &\multicolumn{2}{c}{Predicted} \\ 
    \multicolumn{1}{c}{} & 
    \multicolumn{1}{c|}{} & 
    \multicolumn{1}{c}{Yes} & 
    \multicolumn{1}{c}{No} \\ 
    \cline{2-4}
    \multirow[c]{2}{*}{\rotatebox[origin=tr]{90}{Actual}}
    & Yes  & 100 & 0   \\[1.5ex]
    & No  & 10   & 80 \\ 
    \cline{2-4}
    \end{tabular}
    \quad% ---------------------------
    \begin{tabular}{@{}cc|cc@{}}
    \multicolumn{1}{c}{} &\multicolumn{1}{c}{} &\multicolumn{2}{c}{Predicted} \\ 
    \multicolumn{1}{c}{} & 
    \multicolumn{1}{c|}{} & 
    \multicolumn{1}{c}{Yes} & 
    \multicolumn{1}{c}{No} \\ 
    \cline{2-4}
    \multirow[c]{2}{*}{\rotatebox[origin=tr]{90}{Actual}}
    & Yes  & 100 & 0   \\[1.5ex]
    & No  & 10   & 80 \\ 
    \cline{2-4}
    \end{tabular}

    \par\bigskip
    \begin{tabular}{@{}cc|cc@{}}
    \multicolumn{1}{c}{} &\multicolumn{1}{c}{} &\multicolumn{2}{c}{Predicted} \\ 
    \multicolumn{1}{c}{} & 
    \multicolumn{1}{c|}{} & 
    \multicolumn{1}{c}{Yes} & 
    \multicolumn{1}{c}{No} \\ 
    \cline{2-4}
    \multirow[c]{2}{*}{\rotatebox[origin=tr]{90}{Actual}}
    & Yes  & 100 & 0   \\[1.5ex]
    & No  & 10   & 80 \\ 
    \cline{2-4}
    \end{tabular}
    \quad% ---------------------------
    \begin{tabular}{@{}cc|cc@{}}
    \multicolumn{1}{c}{} &\multicolumn{1}{c}{} &\multicolumn{2}{c}{Predicted} \\ 
    \multicolumn{1}{c}{} & 
    \multicolumn{1}{c|}{} & 
    \multicolumn{1}{c}{Yes} & 
    \multicolumn{1}{c}{No} \\ 
    \cline{2-4}
    \multirow[c]{2}{*}{\rotatebox[origin=tr]{90}{Actual}}
    & Yes  & 100 & 0   \\[1.5ex]
    & No  & 10   & 80 \\ 
    \cline{2-4}
    \end{tabular}
    \end{table}
2

Set each tabular component inside a minipage. If the components within the minipage have differing heights, you can align them using \begin{minipage}[<align>]{<len>} (where <align> could be top or bottom).

enter image description here

\documentclass{article}

\usepackage{multirow,graphicx}

\begin{document}

\begin{table}
  \centering

  \begin{minipage}{.4\linewidth}
    \centering
    {\bfseries\strut Top left title}

    \begin{tabular}{@{}cc|cc@{}}
      \multicolumn{1}{c}{} &\multicolumn{1}{c}{} &\multicolumn{2}{c}{Predicted} \\ 
      \multicolumn{1}{c}{} & 
      \multicolumn{1}{c|}{} & 
      \multicolumn{1}{c}{Yes} & 
      \multicolumn{1}{c}{No} \\ 
      \cline{2-4}
      \multirow[c]{2}{*}{\rotatebox[origin=tr]{90}{Actual}}
      & Yes  & 100 & 0   \\[1.5ex]
      & No  & 10   & 80 \\ 
      \cline{2-4}
    \end{tabular}

    \caption{Top left caption}
  \end{minipage}%
  \quad % ----------------------------------
  \begin{minipage}{.4\linewidth}
    \centering
    {\bfseries\strut Top right title}

    \begin{tabular}{@{}cc|cc@{}}
      \multicolumn{1}{c}{} &\multicolumn{1}{c}{} &\multicolumn{2}{c}{Predicted} \\ 
      \multicolumn{1}{c}{} & 
      \multicolumn{1}{c|}{} & 
      \multicolumn{1}{c}{Yes} & 
      \multicolumn{1}{c}{No} \\ 
      \cline{2-4}
      \multirow[c]{2}{*}{\rotatebox[origin=tr]{90}{Actual}}
      & Yes  & 100 & 0   \\[1.5ex]
      & No  & 10   & 80 \\ 
      \cline{2-4}
    \end{tabular}
    \caption{Top right caption}
  \end{minipage}

  \bigskip

  \begin{minipage}{.4\linewidth}
    \centering
    {\bfseries\strut Bottom left title}

    \begin{tabular}{@{}cc|cc@{}}
      \multicolumn{1}{c}{} &\multicolumn{1}{c}{} &\multicolumn{2}{c}{Predicted} \\ 
      \multicolumn{1}{c}{} & 
      \multicolumn{1}{c|}{} & 
      \multicolumn{1}{c}{Yes} & 
      \multicolumn{1}{c}{No} \\ 
      \cline{2-4}
      \multirow[c]{2}{*}{\rotatebox[origin=tr]{90}{Actual}}
      & Yes  & 100 & 0   \\[1.5ex]
      & No  & 10   & 80 \\ 
      \cline{2-4}
    \end{tabular}
    \caption{Bottom left caption}
  \end{minipage}%
  \quad % ----------------------------------
  \begin{minipage}{.4\linewidth}
    \centering
    {\bfseries\strut Bottom right title}

    \begin{tabular}{@{}cc|cc@{}}
      \multicolumn{1}{c}{} &\multicolumn{1}{c}{} &\multicolumn{2}{c}{Predicted} \\ 
      \multicolumn{1}{c}{} & 
      \multicolumn{1}{c|}{} & 
      \multicolumn{1}{c}{Yes} & 
      \multicolumn{1}{c}{No} \\ 
      \cline{2-4}
      \multirow[c]{2}{*}{\rotatebox[origin=tr]{90}{Actual}}
      & Yes  & 100 & 0   \\[1.5ex]
      & No  & 10   & 80 \\ 
      \cline{2-4}
    \end{tabular}
    \caption{Bottom right caption}
  \end{minipage}
\end{table}

\end{document}

I enjoy the booktabs view a little better:

enter image description here

\documentclass{article}

\usepackage{booktabs,eqparbox}

\begin{document}

\begin{table}
  \centering

  \begin{minipage}{.4\linewidth}
    \centering
    {\bfseries\strut Top left title}

    \begin{tabular}{ l c c }
      \toprule
      & \multicolumn{2}{c}{\bfseries Predicted} \\
      \cmidrule(lr){2-3}
      \bfseries Actual & \itshape Yes & \itshape No \\
      \midrule
      \itshape Yes & \eqmakebox[apval][r]{100} & \eqmakebox[apval][r]{  0} \\
      \itshape No  & \eqmakebox[apval][r]{ 10} & \eqmakebox[apval][r]{ 80} \\
      \bottomrule
    \end{tabular}

    \caption{Top left caption}
  \end{minipage}%
  \quad % ----------------------------------
  \begin{minipage}{.4\linewidth}
    \centering
    {\bfseries\strut Top right title}

    \begin{tabular}{ l c c }
      \toprule
      & \multicolumn{2}{c}{\bfseries Predicted} \\
      \cmidrule(lr){2-3}
      \bfseries Actual & \itshape Yes & \itshape No \\
      \midrule
      \itshape Yes & \eqmakebox[apval][r]{100} & \eqmakebox[apval][r]{  0} \\
      \itshape No  & \eqmakebox[apval][r]{ 10} & \eqmakebox[apval][r]{ 80} \\
      \bottomrule
    \end{tabular}
    \caption{Top right caption}
  \end{minipage}

  \bigskip

  \begin{minipage}{.4\linewidth}
    \centering
    {\bfseries\strut Bottom left title}

    \begin{tabular}{ l c c }
      \toprule
      & \multicolumn{2}{c}{\bfseries Predicted} \\
      \cmidrule(lr){2-3}
      \bfseries Actual & \itshape Yes & \itshape No \\
      \midrule
      \itshape Yes & \eqmakebox[apval][r]{100} & \eqmakebox[apval][r]{  0} \\
      \itshape No  & \eqmakebox[apval][r]{ 10} & \eqmakebox[apval][r]{ 80} \\
      \bottomrule
    \end{tabular}
    \caption{Bottom left caption}
  \end{minipage}%
  \quad % ----------------------------------
  \begin{minipage}{.4\linewidth}
    \centering
    {\bfseries\strut Bottom right title}

    \begin{tabular}{ l c c }
      \toprule
      & \multicolumn{2}{c}{\bfseries Predicted} \\
      \cmidrule(lr){2-3}
      \bfseries Actual & \itshape Yes & \itshape No \\
      \midrule
      \itshape Yes & \eqmakebox[apval][r]{100} & \eqmakebox[apval][r]{  0} \\
      \itshape No  & \eqmakebox[apval][r]{ 10} & \eqmakebox[apval][r]{ 80} \\
      \bottomrule
    \end{tabular}
    \caption{Bottom right caption}
  \end{minipage}
\end{table}

\end{document}

eqparbox's \eqmakebox was just a quick horizontal alignment technique for centred columns.

  • 1
    @user113156: You're welcome. I've added some \struts to ensure a consistent vertical alignment and spacing between the tabular titles. You can see the difference in the post revision history. – Werner Oct 25 '18 at 21:53

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.