我希望根据使用的模型将低高居中

我希望根据使用的模型将低高居中

这是我当前的代码。我无法在 FPCR Prophet Update 中对齐低高列。此外,拾音器向右倾斜,而不是在低高的中间。我怎样才能实现更好的对齐?我试过 chatgpt,但结果却很糟糕。

\begin{table}[H]
\centering
\begin{tabular}{lllllllll}
\toprule
Model & \multicolumn{2}{r}{Pick-up} & \multicolumn{2}{r}{FPCR-Prophet} & \multicolumn{2}{r}{FPCR-Prophet-update} & \multicolumn{2}{r}{Prophet} \\
Version var. & low & high & low & high & low & high & low & high \\
\midrule
h=0 & 1.83 & 1.79 & 1.47 & 5.14 & 2.07 & 2.13 & 0.82 & 6.88 \\
h=1 & 2.74 & 2.67 & 1.32 & 5.52 & 1.97 & 3.17 & 0.83 & 6.12 \\
h=2 & 5.06 & 5.18 & 1.2 & 5.74 & 1.92 & 4.1 & 0.9 & 6.75 \\
h=3 & 8.57 & 9.91 & 1.13 & 6.45 & 2.69 & 5.86 & 0.92 & 7.43 \\
\bottomrule
\end{tabular}
\caption{Simulation results }
\label{your-label}
\end{table}

在此处输入图片描述

答案1

标签的对齐方式Prophet是因为您r在 ; 中指定了对齐方式,而\multicolumn使用c。对于其他的\multicolumns ,最好c也使用 ,但对于较宽的 s ( FPCR-Prophet& FPCR-Prophet-update) ,这无济于事,因为它们太宽了,即比它们下面的两列加起来还要宽。LaTeX 没有很好的功能来进行这种嵌套对齐,但我认为一个简单的解决方案是将两low列向右移动一点。具体要移动多少,你必须通过反复试验才能找到答案。我分别尝试了 3mm 和 9mm。这给了我以下解决方案:

\documentclass{article}

\usepackage{booktabs}
\usepackage{array}

\begin{document}

\begin{table}[h]
\noindent\rule{\textwidth}{1mm}\\
\centering
\begin{tabular}{lll>{\hspace{3mm}}ll>{\hspace{9mm}}llll}
\toprule
Model & \multicolumn{2}{c}{Pick-up} & \multicolumn{2}{c}{FPCR-Prophet} & \multicolumn{2}{c}{FPCR-Prophet-update} & \multicolumn{2}{c}{Prophet} \\
Version var. & low & high & low & high & low & high & low & high \\
\midrule
h=0 & 1.83 & 1.79 & 1.47 & 5.14 & 2.07 & 2.13 & 0.82 & 6.88 \\
h=1 & 2.74 & 2.67 & 1.32 & 5.52 & 1.97 & 3.17 & 0.83 & 6.12 \\
h=2 & 5.06 & 5.18 & 1.2 & 5.74 & 1.92 & 4.1 & 0.9 & 6.75 \\
h=3 & 8.57 & 9.91 & 1.13 & 6.45 & 2.69 & 5.86 & 0.92 & 7.43 \\
\bottomrule
\end{tabular}
\\\noindent\rule{\textwidth}{1mm}
\caption{Simulation results }
\label{your-label}
\end{table}

\end{document}

这两条规则是为了显示文本宽度,正如您所见,整个表格由于 LaTeXarticle类而变得太宽。

在此处输入图片描述

\small我们可以尝试使用字体并使用 删除一些列间空间,使表格稍微小一些@{}。然后偏移量变为 1mm 和 7mm。

\begin{table}[h]
\noindent\rule{\textwidth}{1mm}\\
\centering\small
\begin{tabular}{lll>{\hspace{1mm}}ll>{\hspace{7mm}}ll@{}ll}
\toprule
Model & \multicolumn{2}{c}{Pick-up} & \multicolumn{2}{@{}c}{FPCR-Prophet} & \multicolumn{2}{@{}c}{FPCR-Prophet-update} & \multicolumn{2}{@{}c}{Prophet} \\
Version var. & low & high & low & high & low & high & low & high \\
\midrule
h=0 & 1.83 & 1.79 & 1.47 & 5.14 & 2.07 & 2.13 & 0.82 & 6.88 \\
h=1 & 2.74 & 2.67 & 1.32 & 5.52 & 1.97 & 3.17 & 0.83 & 6.12 \\
h=2 & 5.06 & 5.18 & 1.2 & 5.74 & 1.92 & 4.1 & 0.9 & 6.75 \\
h=3 & 8.57 & 9.91 & 1.13 & 6.45 & 2.69 & 5.86 & 0.92 & 7.43 \\
\bottomrule
\end{tabular}
\\\noindent\rule{\textwidth}{1mm}
\caption{Simulation results }
\label{your-label}
\end{table}

在此处输入图片描述

答案2

我会使用图例,而不是较长的标题。

\documentclass{article}
\usepackage{siunitx,booktabs}

\begin{document}

\begin{table}[htp]
\centering
\setlength{\tabcolsep}{0pt}

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  c
  *{8}{S[table-format=1.2]}
}
\toprule
\smash{\begin{tabular}[t]{c} Version \\ var. \end{tabular}} &
\multicolumn{8}{c}{Model} \\
\cmidrule{2-9}
&
\multicolumn{2}{c}{Pick-up} &
\multicolumn{2}{c}{FPCR-P} &
\multicolumn{2}{c}{FPCR-PU} &
\multicolumn{2}{c}{Prophet} \\
\cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-7} \cmidrule{8-9}
& {low} & {high} & {low} & {high} & {low} & {high} & {low} & {high} \\
\midrule
$h=0$ & 1.83 & 1.79 & 1.47 & 5.14 & 2.07 & 2.13 & 0.82 & 6.88 \\
$h=1$ & 2.74 & 2.67 & 1.32 & 5.52 & 1.97 & 3.17 & 0.83 & 6.12 \\
$h=2$ & 5.06 & 5.18 & 1.2 & 5.74 & 1.92 & 4.1 & 0.9 & 6.75 \\
$h=3$ & 8.57 & 9.91 & 1.13 & 6.45 & 2.69 & 5.86 & 0.92 & 7.43 \\
\bottomrule
\multicolumn{1}{l}{\makebox[0pt][l]{%
  \footnotesize FPCR-P: FPCR-Prophet;\qquad FPCR-PU: FPCR-Prophet-update%
}}
\end{tabular*}

\caption{Simulation results}
\label{your-label}

\end{table}

\end{document}

在此处输入图片描述

相关内容