我正在努力解决 LaTeX 中的布局问题。我希望我的三个表格有一个共同的标题,同时仍然有自己的标题。另外,我需要布局实际上保持不变,因为我需要遵守空间限制。你们中有人知道如何在不实际添加表格的情况下包含一个不调用标题“表格 7:标题”的共同标题吗?我已经尝试在第一个表格语句下添加标题,但这并没有解决我的问题。
谢谢你的帮助。你可以在这篇文章中找到代码和图片。
\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}
答案1
这可以通过包来完成subcaption
。
\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}