![3×2 多表](https://linux22.com/image/406112/3%C3%972%20%E5%A4%9A%E8%A1%A8.png)
我想制作一个包含六个 3x2 格式的单独表格的表格(见附图 :))。我想在六个表格中的每一个表格下添加标题,但不知道该怎么做。此外,我希望能够在 resizebox 配置中使用它。到目前为止,我的代码如下:
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[latin1]{inputenc}
\begin{document}
% Newly defined command:
\newcommand{\specialcell}[2][c]{%
\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}
% My Code
\begin{tabular}{p{1.5cm} c|c}
& \specialcell{White \\ Noise} & \specialcell{Pink \\ Noise} \\
\hline
\specialcell{NRMSE \\ Fit [\%]} & 92.802 & 89.530 \\
\hline
\specialcell{NMSE \\ Fit [\%]} & 99.482 & 98.904 \\
\hline
$R^2$ & 0.995 & 9.989
\end{tabular} \begin{tabular}{p{1.5cm} c|c}
& \specialcell{White \\ Noise} & \specialcell{Pink \\ Noise} \\
\hline
\specialcell{NRMSE \\ Fit [\%]} & 92.802 & 89.530 \\
\hline
\specialcell{NMSE \\ Fit [\%]} & 99.482 & 98.904 \\
\hline
$R^2$ & 0.995 & 9.989
\end{tabular} \begin{tabular}{p{1.5cm} c|c}
& \specialcell{White \\ Noise} & \specialcell{Pink \\ Noise} \\
\hline
\specialcell{NRMSE \\ Fit [\%]} & 92.802 & 89.530 \\
\hline
\specialcell{NMSE \\ Fit [\%]} & 99.482 & 98.904 \\
\hline
$R^2$ & 0.995 & 9.989
\end{tabular} \begin{tabular}{p{1.5cm} c|c}
& \specialcell{White \\ Noise} & \specialcell{Pink \\ Noise} \\
\hline
\specialcell{NRMSE \\ Fit [\%]} & 92.802 & 89.530 \\
\hline
\specialcell{NMSE \\ Fit [\%]} & 99.482 & 98.904 \\
\hline
$R^2$ & 0.995 & 9.989
\end{tabular} \begin{tabular}{p{1.5cm} c|c}
& \specialcell{White \\ Noise} & \specialcell{Pink \\ Noise} \\
\hline
\specialcell{NRMSE \\ Fit [\%]} & 92.802 & 89.530 \\
\hline
\specialcell{NMSE \\ Fit [\%]} & 99.482 & 98.904 \\
\hline
$R^2$ & 0.995 & 9.989
\end{tabular} \begin{tabular}{p{1.5cm} c|c}
& \specialcell{White \\ Noise} & \specialcell{Pink \\ Noise} \\
\hline
\specialcell{NRMSE \\ Fit [\%]} & 92.802 & 89.530 \\
\hline
\specialcell{NMSE \\ Fit [\%]} & 99.482 & 98.904 \\
\hline
$R^2$ & 0.995 & 9.989
\end{tabular}
\end{document}
答案1
根据subcaption
的subtable
环境,您可能对以下建议感到满意:
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[latin1]{inputenc}
\usepackage{subcaption}
\begin{document}
% Newly defined command:
\newcommand{\specialcell}[2][c]{%
\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}
% My Code
\begin{table}
\caption{common caption for all tables}
\begin{subtable}{0.5\textwidth}
\centering
\begin{tabular}{p{1.5cm} c|c}
& \specialcell{White \\ Noise} & \specialcell{Pink \\ Noise} \\
\hline
\specialcell{NRMSE \\ Fit [\%]} & 92.802 & 89.530 \\
\hline
\specialcell{NMSE \\ Fit [\%]} & 99.482 & 98.904 \\
\hline
$R^2$ & 0.995 & 9.989
\end{tabular}
\caption{individual caption}
\end{subtable}%
\begin{subtable}{0.5\textwidth}
\centering
\begin{tabular}{p{1.5cm} c|c}
& \specialcell{White \\ Noise} & \specialcell{Pink \\ Noise} \\
\hline
\specialcell{NRMSE \\ Fit [\%]} & 92.802 & 89.530 \\
\hline
\specialcell{NMSE \\ Fit [\%]} & 99.482 & 98.904 \\
\hline
$R^2$ & 0.995 & 9.989
\end{tabular}
\caption{individual caption}
\end{subtable}
\medskip
\begin{subtable}{0.5\textwidth}
\centering
\begin{tabular}{p{1.5cm} c|c}
& \specialcell{White \\ Noise} & \specialcell{Pink \\ Noise} \\
\hline
\specialcell{NRMSE \\ Fit [\%]} & 92.802 & 89.530 \\
\hline
\specialcell{NMSE \\ Fit [\%]} & 99.482 & 98.904 \\
\hline
$R^2$ & 0.995 & 9.989
\end{tabular}
\caption{individual caption}
\end{subtable}%
\begin{subtable}{0.5\textwidth}
\centering
\begin{tabular}{p{1.5cm} c|c}
& \specialcell{White \\ Noise} & \specialcell{Pink \\ Noise} \\
\hline
\specialcell{NRMSE \\ Fit [\%]} & 92.802 & 89.530 \\
\hline
\specialcell{NMSE \\ Fit [\%]} & 99.482 & 98.904 \\
\hline
$R^2$ & 0.995 & 9.989
\end{tabular}
\caption{individual caption}
\end{subtable}
\medskip
\begin{subtable}{0.5\textwidth}
\centering
\begin{tabular}{p{1.5cm} c|c}
& \specialcell{White \\ Noise} & \specialcell{Pink \\ Noise} \\
\hline
\specialcell{NRMSE \\ Fit [\%]} & 92.802 & 89.530 \\
\hline
\specialcell{NMSE \\ Fit [\%]} & 99.482 & 98.904 \\
\hline
$R^2$ & 0.995 & 9.989
\end{tabular}
\caption{individual caption}
\end{subtable}%
\begin{subtable}{0.5\textwidth}
\centering
\begin{tabular}{p{1.5cm} c|c}
& \specialcell{White \\ Noise} & \specialcell{Pink \\ Noise} \\
\hline
\specialcell{NRMSE \\ Fit [\%]} & 92.802 & 89.530 \\
\hline
\specialcell{NMSE \\ Fit [\%]} & 99.482 & 98.904 \\
\hline
$R^2$ & 0.995 & 9.989
\end{tabular}
\caption{individual caption}
\end{subtable}
\end{table}
\end{document}
两个无关的建议可以帮助您简化生活:\makecell
同名包中的命令提供与您的\specialcell
命令类似的结果,同时允许通过可选参数定义水平对齐。除了使用p
第一列和手动换行符外,您还可以切换到m
类型列和自动换行符。
\begin{table}
\caption{common caption for all tables}
\begin{subtable}{0.5\textwidth}
\centering
\begin{tabular}{l c|c}
& \makecell{White \\ Noise} & \makecell{Pink \\ Noise} \\
\hline
\makecell[l]{NRMSE \\ Fit [\%]} & 92.802 & 89.530 \\
\hline
\makecell[l]{NMSE \\ Fit [\%]} & 99.482 & 98.904 \\
\hline
$R^2$ & 0.995 & 9.989
\end{tabular}
\caption{individual caption}
\end{subtable}%
\begin{subtable}{0.5\textwidth}
\centering
\begin{tabular}{m{1.5cm} c|c}
& \makecell{White \\ Noise} & \makecell{Pink \\ Noise} \\
\hline
NRMSE Fit [\%] & 92.802 & 89.530 \\
\hline
NMSE Fit [\%] & 99.482 & 98.904 \\
\hline
$R^2$ & 0.995 & 9.989
\end{tabular}
\caption{individual caption}
\end{subtable}
\end{table}
答案2
子表布局略有不同:
\documentclass{article}
\usepackage{geometry}
\usepackage{siunitx}
\usepackage{booktabs, makecell}
\renewcommand\cellset{\renewcommand\arraystretch{0.84}}
\usepackage{caption}
\usepackage[skip=3ex]{subcaption}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
\begin{document}
% My Code
\begin{table}[ht]
\caption{?}
\label{tab:tables}
\centering
\begin{subtable}{0.4\linewidth}
\centering
\begin{tabular}{ l *{2}{S[table-format=2.3]} }
& {\makecell{White\\ Noise}}
& {\makecell{Pink\\ Noise}} \\
\midrule
NRMSE Fit [\%] & 92.802 & 89.530 \\
\hline
NMSE Fit [\%] & 99.482 & 98.904 \\
\midrule
$R^2$ & 0.995 & 9.989
\end{tabular}
\caption{First}
\end{subtable}
\hfil
\begin{subtable}{0.4\linewidth}
\centering
\begin{tabular}{ c *{2}{S[table-format=2.3]} }
& {\makecell{White\\ Noise}}
& {\makecell{Pink\\ Noise}} \\
\midrule
NRMSE Fit [\%] & 92.802 & 89.530 \\
\hline
NMSE Fit [\%] & 99.482 & 98.904 \\
\midrule
$R^2$ & 0.995 & 9.989
\end{tabular}
\caption{second}
\end{subtable}
\begin{subtable}{0.4\linewidth}
\centering
\begin{tabular}{ c *{2}{S[table-format=2.3]} }
& {\makecell{White\\ Noise}}
& {\makecell{Pink\\ Noise}} \\
\midrule
NRMSE Fit [\%] & 92.802 & 89.530 \\
\hline
NMSE Fit [\%] & 99.482 & 98.904 \\
\midrule
$R^2$ & 0.995 & 9.989
\end{tabular}
\caption{Third}
\end{subtable}
\hfil
\begin{subtable}{0.4\linewidth}
\centering
\begin{tabular}{ c *{2}{S[table-format=2.3]} }
& {\makecell{White\\ Noise}}
& {\makecell{Pink\\ Noise}} \\
\midrule
NRMSE Fit [\%] & 92.802 & 89.530 \\
\hline
NMSE Fit [\%] & 99.482 & 98.904 \\
\midrule
$R^2$ & 0.995 & 9.989
\end{tabular}
\caption{Fourth}
\end{subtable}
\begin{subtable}{0.4\linewidth}
\centering
\begin{tabular}{ c *{2}{S[table-format=2.3]} }
& {\makecell{White\\ Noise}}
& {\makecell{Pink\\ Noise}} \\
\midrule
NRMSE Fit [\%] & 92.802 & 89.530 \\
\hline
NMSE Fit [\%] & 99.482 & 98.904 \\
\midrule
$R^2$ & 0.995 & 9.989
\end{tabular}
\caption{Fifth}
\end{subtable}
\hfil
\begin{subtable}{0.4\linewidth}
\centering
\begin{tabular}{ c *{2}{S[table-format=2.3]} }
& {\makecell{White\\ Noise}}
& {\makecell{Pink\\ Noise}} \\
\midrule
NRMSE Fit [\%] & 92.802 & 89.530 \\
\hline
NMSE Fit [\%] & 99.482 & 98.904 \\
\midrule
$R^2$ & 0.995 & 9.989
\end{tabular}
\caption{Sixt}
\end{subtable}
\end{table}
\end{document}
(红线表示文本边框)
答案3
我感觉使用这六个表格并不是呈现信息的最佳方式。信息冗余且分散。
可以使用一个更大的表格。您可以在表格中留出一些空间以实现更好的可视化,并在文本中和表格上方的单个标题中提及详细信息。例如,NRMSE
和NMSE
是该领域中已知的术语,您可以省略单词fit
和(%)
并在上面的文本或标题中提及它们。现在,每个先前的子标题都可以填充第一列中的表格单元格。列类型X
更适合这些。
\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[margin=1in]{geometry}
\usepackage{tabularx,booktabs}
\begin{document}
\begin{table}
\caption{My bigger caption for the whole table ..}
\begin{tabularx}{\textwidth}{@{} X *6{c} @{}}
\toprule
& \multicolumn{3}{c}{White noise} & \multicolumn{3}{c}{Pink noise} \\ \cmidrule(r){2-4} \cmidrule(l){5-7}
& NRMSE & NMSE & $R^2$ & NRMSE & NMSE & $R^2$ \\ \midrule
Caption 1 (Much longer text will go here ...) & 92.802 & 99.482 & 0.995 & 89.530 & 98.904 & 9.989 \\
Caption 2 (Much longer text will go here ...) & 92.802 & 99.482 & 0.995 & 89.530 & 98.904 & 9.989 \\
Caption 3 (Much longer text will go here ...) & 92.802 & 99.482 & 0.995 & 89.530 & 98.904 & 9.989 \\
Caption 4 (Much longer text will go here ...) & 92.802 & 99.482 & 0.995 & 89.530 & 98.904 & 9.989 \\
Caption 5 (Much longer text will go here ...) & 92.802 & 99.482 & 0.995 & 89.530 & 98.904 & 9.989 \\
Caption 6 (Much longer text will go here ...) & 92.802 & 99.482 & 0.995 & 89.530 & 98.904 & 9.989 \\ \bottomrule
\end{tabularx}
\end{table}
\end{document}
答案4
\documentclass[12pt]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{xcolor,lipsum,subcaption}
\begin{document}
\noindent
\begin{table}
\begin{minipage}{0.33\textwidth}
\centering
\begin{tabular}{|c|c|c|c|}
\hline
A11 & A12 & A13 & A14 \\
\hline
A21 & A22 & A23 & A24 \\
\hline
A31 & A32 & A33 & A34 \\
\hline
A41 & A42 & A43 & A44 \\
\hline
\end{tabular}
\centerline{(a) First Table}
\end{minipage}
\begin{minipage}{0.33\textwidth}
\centering
\begin{tabular}{|c|c|c|c|}
\hline
B11 & B12 & B13 & B14 \\
\hline
B21 & B22 & B23 & B24 \\
\hline
B31 & B32 & B33 & B34 \\
\hline
B41 & B42 & B43 & B44 \\
\hline
\end{tabular}
\centerline{(b)Second Table}
\end{minipage}
\begin{minipage}{0.33\textwidth}
\centering
\begin{tabular}{|c|c|c|c|}
\hline
C11 & C12 & C13 & C14 \\
\hline
C21 & C22 & C23 & C24 \\
\hline
C31 & C32 & C33 & C34 \\
\hline
C41 & C42 & C43 & C44 \\
\hline
\end{tabular}
\centerline{(c) Second Table}
\end{minipage}
\end{table}
\end{document}
请参阅以下内容关联作者使用 minipage 添加子表。我使用了此处的部分代码