0

I am struggling with a lay-out problem in LaTeX. I would like my three tables to have a common caption whilst still having their own caption. Also I need the lay-out to practically remain the same as I need to adhere to space limits. Does any of you know how to include a common caption that does not call the caption 'Table 7: Caption' without actually adding a table. I already tried to add a caption under the first table statement but that didn't solve my issue.

Thank you for your help. You can find the code and a picture attached to this post.

\begin{table}[]
    \begin{minipage}{.25\linewidth}
      \centering
        \caption{table A} \label{Table B}
        \begin{tabular}{|l|ll}

        \cline{1-1}
        \textbf{A} &                                     &                                       \\ \hline
        \textbf{A1}      & \multicolumn{1}{l|}{\cellcolor{blue!25}\textbf{A2}} & \multicolumn{1}{l|}{\cellcolor{blue!25}\textbf{3}} \\ \hline
        \textit{p1}                & \multicolumn{1}{l|}{x}             & \multicolumn{x}{l|}{1}                \\ \hline
        \end{tabular}
    \end{minipage} 
         \begin{minipage}{\linewidth}
     \caption{table B} \label{table B}
     \centering
       \begin{tabular}{|l|}

        \cline{1-1}
        \textbf{B}  \\ \hline
        \textbf{B1} \\ \hline
        \textit{b1}               \\ \hline
        \end{tabular}
        \end{minipage}%
        \\
    \begin{minipage}{\linewidth}
        \caption{Table C} \label{Table C}
        \centering
         \begin{tabular}{|l|ll}
        \cline{1-1}
        \textbf{C} &                                    &                                           \\ \hline
        \textbf{ID}       & \multicolumn{1}{l|}{\cellcolor{blue!25}\textbf{C1}} & \multicolumn{1}{l|}{\cellcolor{blue!25}\textbf{C2}} \\ \hline
        \textit{c1}                & \multicolumn{1}{l|}{c1}         & \multicolumn{1}{l|}{c2}  \\ \hline
        \end{tabular}
    \end{minipage} 
   
\end{table}

enter image description here

1 Answer 1

1

This can be done with the subcaption package.

\documentclass{article}

\usepackage{subcaption}
\usepackage[table]{xcolor}

\begin{document}

We refer to Table~\ref{Table ABC} and its parts~\ref{table A}, \ref{table B} and \ref{table C}.

\begin{table}
  \caption{A table with 3 subtables}\label{Table ABC}
    \begin{minipage}{.25\linewidth}
      \centering
        \subcaption{Table A} \label{table A}
        \begin{tabular}{|l|ll}

        \cline{1-1}
        \textbf{A} &                                     &                                       \\ \hline
        \textbf{A1}      & \multicolumn{1}{l|}{\cellcolor{blue!25}\textbf{A2}} & \multicolumn{1}{l|}{\cellcolor{blue!25}\textbf{3}} \\ \hline
        \textit{p1}                & \multicolumn{1}{l|}{x}             & \multicolumn{1}{l|}{1}                \\ \hline
        \end{tabular}
    \end{minipage} 
         \begin{minipage}{\linewidth}
     \subcaption{Table B} \label{table B}
     \centering
       \begin{tabular}{|l|}

        \cline{1-1}
        \textbf{B}  \\ \hline
        \textbf{B1} \\ \hline
        \textit{b1}               \\ \hline
        \end{tabular}
        \end{minipage}%
        \\
    \begin{minipage}{\linewidth}
        \subcaption{Table C} \label{table C}
        \centering
         \begin{tabular}{|l|ll}
        \cline{1-1}
        \textbf{C} &                                    &                                           \\ \hline
        \textbf{ID}       & \multicolumn{1}{l|}{\cellcolor{blue!25}\textbf{C1}} & \multicolumn{1}{l|}{\cellcolor{blue!25}\textbf{C2}} \\ \hline
        \textit{c1}                & \multicolumn{1}{l|}{c1}         & \multicolumn{1}{l|}{c2}  \\ \hline
        \end{tabular}
    \end{minipage} 
   
\end{table}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .