我希望有一个易于阅读的表格。我对两个数据集 A 和 B 分别进行了 2 次计算。每次计算我都会得到三个输出参数,这些参数取决于 3 个输入模型。
理想情况下,这将是一张只使用一半页面(列宽)的小表格。否则,页面顶部的文本宽度就可以了。我期待您的想法。我在 tex overflow 上找不到任何可以帮助我处理这张表格的东西。
应该看到的是第 1 列与第 2 列的比较(对模型的轻微调整会对参数 x、y、z 产生影响)。以及第 3 列与第 4 列的比较。然后需要比较每一列以比较这两个数据集。
谢谢!
\documentclass[twocolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath} % Advanced maths commands
\usepackage{amssymb} % Extra maths symbols
\usepackage{multicol} % Multi-column entries in tables
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{multicol}
\usepackage{blindtext}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=20mm,
right=20mm,
top=20mm,
bottom=20mm
}
\begin{document}
\Blindtext
\begin{table*}\centering
{\def\arraystretch{1.1}\tabcolsep=4pt
\begin{tabular}{@{}lccccc@{}}\hline\hline
Data set& \multicolumn{2}{c}{Data A } & \phantom{abc}& \multicolumn{2}{c}{Data B} \\ \cline{2-3} \cline{5-6}
\multirow{3}{*}{Models}
&Model1 ($x>29$)& Model1 ($x>29$)& &Model1 ($x>29$)& Model1 ($x>29$)\\
& Model2 ($2\leq x \leq 29$)& Model2 ($11\leq x \leq 29$)&& Model2 ($2\leq x \leq 29$)& Model2 ($11\leq x \leq 29$)\\
& Model3.a ($2\leq x \leq 29$)& Model3.b ($2\leq x \leq 10$)&& Model3.a ($2\leq x \leq 29$)& Model3.b ($2\leq x \leq 10$)\\\midrule
x & $0.1^{+0.005}_{-0.006}$ &$0.2^{+0.006}_{-0.007}$&&$0.15\pm 0.007$ &$0.25^{+0.006}_{-0.005}$ \\
y & $3\pm 0.02$ &$3.^{+0.01}_{-0.01}$ &&$3.\pm 0.02$ &$3.\pm 0.01$ \\
z & $7\pm 0.1$ &$7\pm 0.1$ &&$7\pm 0.3$ &$ 8.\pm 0.1$ \\
\hline
\end{tabular}}
\caption{Parameter constraints from three different models (Model1, Model2, Model3). For model 3 we consider the base model 3.a and an extension model 3.b. The parameter x denotes the range of values that we are using for each model. The output of the computations are the summary statistic x, y and z. We perform the same operations on both data sets A and B.}
\label{tab:tab_test}
\end{table*}
\Blindtext
\blindtext
\blindtext
\blindtext
\end{document}
答案1
我发现还有很多改进的空间。
对于不确定性,无论是否对称,我建议一个命令\data
,该命令接收主要数字作为参数,然后是不确定性;如果存在中间可选参数,则意味着不对称不确定性。
“模型”可以排版在嵌套的表格中,这样我们就可以对齐数据。
\tabcolsep
我们可以使用来避免猜测tabular*
。
\documentclass[twocolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath} % Advanced maths commands
\usepackage{amssymb} % Extra maths symbols
\usepackage{multicol} % Multi-column entries in tables
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{multicol}
\usepackage{blindtext}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
% left=20mm,
% right=20mm,
% top=20mm,
% bottom=20mm
}
%\usepackage{xparse}% uncomment for LaTeX prior to 2020-10-01
\NewDocumentCommand{\data}{mom}{%
\ensuremath{%
#1\IfNoValueTF{#2}{\pm#3}{_{-#2}^{+#3}}%
}%
}
\begin{document}
\Blindtext
\begin{table*}
\centering
\newcommand{\Models}[1]{% local command
\begin{tabular}{@{}l@{\ }l@{}}#1\end{tabular}%
}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}l*{4}{@{}c}@{}}
\toprule
Data set &
\multicolumn{2}{c}{Data A} &
\multicolumn{2}{c}{Data B} \\
\cmidrule{2-3} \cmidrule{4-5}
Models &
\Models{
Model1 & ($x>29$) \\
Model2 & ($2\leq x \leq 29$) \\
Model3.a & ($2\leq x \leq 29$)
} &
\Models{
Model1 & ($x>29$) \\
Model2 & ($11\leq x \leq 29$) \\
Model3.b & ($2\leq x \leq 10$)
} &
\Models{
Model1 & ($x>29$) \\
Model2 & ($2\leq x \leq 29$) \\
Model3.a & ($2\leq x \leq 29$)
} &
\Models{
Model1 & ($x>29$)\\
Model2 & ($11\leq x \leq 29$)\\
Model3.b & ($2\leq x \leq 10$)
} \\
\midrule
$x$ & \data{0.1}[0.006]{0.005} & \data{0.2}[0.007]{0.006}
& \data{0.1}{0.007} & \data{0.25}[0.005]{0.006} \\
\addlinespace
$y$ & \data{3}{0.02} & \data{3.}[0.01]{0.01} & \data{3.}{0.02} & \data{3.}{0.01} \\
\addlinespace
$z$ & \data{7}{0.1} & \data{7}{0.1} & \data{7}{0.3} & \data{8}{0.1} \\
\bottomrule
\end{tabular*}
\caption{Parameter constraints from three different models (Model1, Model2, Model3).
For model 3 we consider the base model 3.a and an extension model 3.b. The parameter
$x$ denotes the range of values that we are using for each model. The output of the
computations are the summary statistic x, y and z. We perform the same operations
on both data sets A and B.}
\label{tab:tab_test}
\end{table*}
\Blindtext
\blindtext
\blindtext
\blindtext
\end{document}
通过删除重复,您可以获得更紧凑的输出。
\documentclass[twocolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath} % Advanced maths commands
\usepackage{amssymb} % Extra maths symbols
\usepackage{multicol} % Multi-column entries in tables
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{multicol}
\usepackage{blindtext}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
% left=20mm,
% right=20mm,
% top=20mm,
% bottom=20mm
}
%\usepackage{xparse}% uncomment for LaTeX prior to 2020-10-01
\NewDocumentCommand{\data}{mom}{%
\ensuremath{%
#1\IfNoValueTF{#2}{\pm#3}{_{-#2}^{+#3}}%
}%
}
\begin{document}
\Blindtext
\begin{table*}
\centering
\newcommand{\Models}[1]{% local command
\begin{tabular}[t]{@{}l@{\ }l@{}}#1\end{tabular}%
}
\begin{tabular}{@{}l*{4}{c}@{}}
\toprule
Data set &
\multicolumn{2}{c}{Data A} &
\multicolumn{2}{c}{Data B} \\
\cmidrule(lr){2-3} \cmidrule(l){4-5}
Models &
\Models{
1 & ($x>29$) \\
2 & ($2\leq x \leq 29$) \\
3.a & ($2\leq x \leq 29$)
} &
\Models{
1 & ($x>29$) \\
2 & ($11\leq x \leq 29$) \\
3.b & ($2\leq x \leq 10$)
} &
\Models{
1 & ($x>29$) \\
2 & ($2\leq x \leq 29$) \\
3.a & ($2\leq x \leq 29$)
} &
\Models{
1 & ($x>29$)\\
2 & ($11\leq x \leq 29$)\\
3.b & ($2\leq x \leq 10$)
} \\
\midrule
$x$ & \data{0.1}[0.006]{0.005} & \data{0.2}[0.007]{0.006}
& \data{0.1}{0.007} & \data{0.25}[0.005]{0.006} \\
\addlinespace
$y$ & \data{3}{0.02} & \data{3.}[0.01]{0.01} & \data{3.}{0.02} & \data{3.}{0.01} \\
\addlinespace
$z$ & \data{7}{0.1} & \data{7}{0.1} & \data{7}{0.3} & \data{8}{0.1} \\
\bottomrule
\end{tabular}
\caption{Parameter constraints from three different models (Model1, Model2, Model3).
For model 3 we consider the base model 3.a and an extension model 3.b. The parameter
$x$ denotes the range of values that we are using for each model. The output of the
computations are the summary statistic x, y and z. We perform the same operations
on both data sets A and B.}
\label{tab:tab_test}
\end{table*}
\Blindtext
\blindtext
\blindtext
\blindtext
\end{document}
答案2
以下内容可以作为起点。
\documentclass[twocolumn]{article}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}
\begin{table*}\centering
\begin{tabular}{@{}lllll@{}}
\toprule
Data set& \multicolumn{2}{c}{Data A } & \multicolumn{2}{c}{Data B} \\ \cmidrule(r){2-3} \cmidrule(l){4-5}
Models
&LONGNAME ABC & LONGNAME ABC &LONGNAME ABC & LONGNAME ABC \\
& ($x>29$) & ($x>29$) & ($x>29$) & ($x>29$)\\
\addlinespace
& LONGNAME DEF & LONGNAME DEF & LONGNAME DEF & LONGNAME DEF \\
& ($2\leq x \leq 29$) & ($11\leq x \leq 29$)& ($2\leq x \leq 29$) & ($11\leq x \leq 29$)\\
\addlinespace
& LONGNAME HIJ1.0 & LONGNAME HIJ2.0 & LONGNAME HIJ1.0 & LONGNAME HIJ2.0 \\
& ($2\leq x \leq 29$) & ($2\leq x \leq 10$)& ($2\leq x \leq 29$) & ($2\leq x \leq 10$)\\
\midrule
x & $0.1^{+0.005}_{-0.006}$ &$0.2^{+0.006}_{-0.007}$&$0.15\pm 0.007$ &$0.25^{+0.006}_{-0.005}$ \\
\addlinespace
y & $3\pm 0.02$ &$3.^{+0.01}_{-0.01}$ &$3.\pm 0.02$ &$3.\pm 0.01$ \\
\addlinespace
z & $7\pm 0.1$ &$7\pm 0.1$ &$7\pm 0.3$ &$ 8.\pm 0.1$ \\
\bottomrule
\end{tabular}
\caption{Test}
\label{tab:tab_test}
\end{table*}
\end{document}
答案3
基于猜测(提供的信息令人困惑)。因此,我仅限于表格设计的一些 LaTeX 方面:
\documentclass[twocolumn]{article}
\usepackage{geometry}
\geometry{a4paper,
total={170mm,257mm},
margin=20mm
}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{booktabs, multirow, tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\begin{document}
\begin{table*}
\centering
\setlength\tabcolsep{2pt}
\begin{tabularx}{\linewidth}{@{} lCCCC @{}}
\toprule
Data set
& \multicolumn{2}{c}{Data A }
& \multicolumn{2}{c}{Data B} \\
\cmidrule(lr){2-3}
\cmidrule(lr){4-5}
\multirow{3}{*}{Models}
& Model 1 ($x>29$)\par
Model 2 ($2\leq x \leq 29$)\par
Model 3 ($2\leq x \leq 29$)
& Model 1 ($x>29$)\par
Model 2 ($11\leq x \leq 29$)\par
Model 3a ($2\leq x \leq 10$)
& Model2 ($x>29$)\par
Model 2 ($2\leq x \leq 29$)\par
Model 3b ($2\leq x \leq 29$)
& Model 1 ($x>29$)\par
Model 2 ($11\leq x \leq 29$)\par
Model 3c ($2\leq x \leq 10$) \\
\midrule
x & $0.1^{+0.005}_{-0.006}$
& $0.2^{+0.006}_{-0.007}$
& $0.15\pm 0.007$
& $0.25^{+0.006}_{-0.005}$ \\
\addlinespace
y & $3\pm 0.02$
& $3.^{+0.01}_{-0.01}$
& $3.\pm 0.02$
& $3.\pm 0.01$ \\
\addlinespace
z & $7\pm 0.1$
& $7\pm 0.1$
& $7\pm 0.3$
& $8.\pm 0.1$ \\
\bottomrule
\end{tabularx}
\caption{Test}
\label{tab:tab_test}
\end{table*}
\end{document}
(红线显示页面布局摘录)
编辑:
或者使用包\makecell
中定义的makecell
:
\documentclass[twocolumn]{article}
\usepackage{geometry}
\geometry{a4paper,
total={170mm,257mm},
margin=20mm
}
\usepackage{booktabs, makecell, multirow, tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\begin{document}
\begin{table*}
\centering
\setlength\tabcolsep{2pt}
\begin{tabularx}{\linewidth}{@{} lCCCC @{}}
\toprule
Data set
& \multicolumn{2}{c}{Data A }
& \multicolumn{2}{c}{Data B} \\
\cmidrule(r){2-3}
\cmidrule{4-5}
Models
& \makecell[l]{Model 1 ($x>29$)\\
Model 2 ($2\leq x \leq 29$)\\
Model 3 ($2\leq x \leq 29$)}
& \makecell[l]{Model 1 ($x>29$)\\
Model 2 ($11\leq x \leq 29$)\\
Model 3a ($2\leq x \leq 10$)}
& \makecell[l]{Model2 ($x>29$)\\
Model 2 ($2\leq x \leq 29$)\\
Model 3b ($2\leq x \leq 29$)}
& \makecell[l]{Model 1 ($x>29$)\\
Model 2 ($11\leq x \leq 29$)\\
Model 3c ($2\leq x \leq 10$)} \\
\midrule
x & $0.1^{+0.005}_{-0.006}$
& $0.2^{+0.006}_{-0.007}$
& $0.15\pm 0.007$
& $0.25^{+0.006}_{-0.005}$ \\
\addlinespace
y & $3\pm 0.02$
& $3.^{+0.01}_{-0.01}$
& $3.\pm 0.02$
& $3.\pm 0.01$ \\
\addlinespace
z & $7\pm 0.1$
& $7\pm 0.1$
& $7\pm 0.3$
& $8.\pm 0.1$ \\
\bottomrule
\end{tabularx}
\caption{Test}
\label{tab:tab_test}
\end{table*}
\end{document}