我想根據所使用的模型將低高居中

我想根據所使用的模型將低高居中

這是我目前的程式碼。我無法在 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,但對於較寬的 ( 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我們可以嘗試透過使用字體並使用 刪除一些列間空間來使表格小一點@{}。然後移位變成 1 毫米和 7 毫米。

\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}

在此輸入影像描述

相關內容