![在每个表格上方/下方添加标题和说明](https://linux22.com/image/384805/%E5%9C%A8%E6%AF%8F%E4%B8%AA%E8%A1%A8%E6%A0%BC%E4%B8%8A%E6%96%B9%2F%E4%B8%8B%E6%96%B9%E6%B7%BB%E5%8A%A0%E6%A0%87%E9%A2%98%E5%92%8C%E8%AF%B4%E6%98%8E.png)
我正在尝试创建如下所示的 4 个表格:但是我想为每个表格添加一个标题tabular
并在每个表格下方添加一个标题tabular
。
如果您对我该如何进行有任何建议那就太好了。
\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}
答案1
将每个tabular
组件设置在 内minipage
。如果 内的组件minipage
高度不同,则可以使用 对齐它们\begin{minipage}[<align>]{<len>}
(其中<align>
可以是t
op 或b
ottom)。
\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}
我喜欢booktabs
视图稍微好一点:
\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
只是一种针对c
输入列的快速水平对齐技术。