![表格在 Latex Overleaf 中未按预期呈现](https://linux22.com/image/456652/%E8%A1%A8%E6%A0%BC%E5%9C%A8%20Latex%20Overleaf%20%E4%B8%AD%E6%9C%AA%E6%8C%89%E9%A2%84%E6%9C%9F%E5%91%88%E7%8E%B0.png)
我正在用 latex 制作表格。我使用了tabularray
overleaf 中的包。但是,标题文本缺失。我分享了我尝试过的代码和生成的输出。
\usepackage[version=4]{mhchem}
\usepackage{tabularray}
\begin{table*}[t]
\begin{threeparttable}[b]
\caption{Characteristics of Training and Testing Data\label{tab:table4}}
\centering
\begin{tblr}{p{0.05\linewidth} p{0.06\linewidth} p{0.06\linewidth} p{0.06\linewidth} p{0.06\linewidth} p{0.06\linewidth} p{0.06\linewidth} p{0.06\linewidth} p{0.06\linewidth} p{0.06\linewidth} p{0.06\linewidth} }
\hline
\SetCell[c=6]{c} {Training Data} & & & & &\SetCell[c=5]{c}{Testing Data}\\
\hline
Zone & Mean(cm) & Std(cm) & Max(cm) & Skew & Kurtosis & Mean(cm) & Std(cm) & Max(cm) & Skew & Kurtosis \\
\hline
Zall & 44.08 & 37.44& 373.3& 2.48& 9.71& 54.23& 41.76& 325.1& 2.03& 6.19\\
\hline
Z1& 74.52& 32.23& 157.4& -0.17& -0.42& 82.9& 26.26& 137.5& -0.97& 0.38\\
\hline
Z2& 13.20& 10.37& 50.80& 1.42& 1.34& 12.06& 9.91& 53.34& 1.95& 4.64\\
\hline
Z3& 37.25& 22.18& 109.22& 0.24& -0.58& 46.67& 26.31& 208& 0.3& -0.03\\
\hline
Z4& 36.05& 16.11& 88.9& -0.03& -0.37& 40.69& 21.48& 78.75& 0.13& -1.03\\
\hline
Z5& 35.95& 20.21& 160.02& 0.76& 0.97& 41.57& 21.79& 170.2& 1.21& 3.17\\
\hline
Z6& 59.46& 56.26& 373.3& 1.60& 2.87& 75.05& 58.31& 325.1& 1.20& 1.52\\
\hline
\end{tblr}
\begin{tablenotes}[flushleft]
\item [*]Note: In tha table Std, Max indicated standard deviation and maximum of snow depth observations in a given zone.
\end{tablenotes}
\end{threeparttable}
\end {table*}
如您所见,标题行的文本以及脚注的对齐也出现了错误。
输出如下:
答案1
我建议使用talltblr
来自的环境tabularray
,它结合了tblr
和,longtblr
并且工作方式与类似threeparttable
。
我添加了siunitx
帮助格式化数字。但是,由于表格很宽,我还建议使用sidewaystable
而不是常规table
以下是表格
\documentclass{article}
\usepackage[version=4]{mhchem}
\usepackage{xcolor}
\usepackage{tabularray}
\usepackage{rotating}
\usepackage{kantlipsum}
\UseTblrLibrary{siunitx,booktabs}
\begin{document}
\kant[1][1]
The reference to the table~\ref{tab:table4}
\begin{sidewaystable}
\centering
\begin{talltblr}[
caption = {Characteristics of Training and Testing Data},
label = {tab:table4},
note{*} = {Note: In tha table Std, Max indicated standard deviation and maximum of snow depth observations in a given zone.},
]{
width = \linewidth,
stretch = 1.15,
colspec = {
X
*2{Q[si={table-format=2.2},c]}
Q[si={table-format=3.2},c]
*2{Q[si={table-format=-1.2},c]}
*2{Q[si={table-format=2.2},c]}
Q[si={table-format=3.2},c]
*2{Q[si={table-format=-1.2},c]}
},
row{1,2} = {guard},
hline{2} = {2-6}{leftpos=-0.5, rightpos=-0.5, endpos},
hline{2} = {7-11}{leftpos=-0.5, rightpos=-0.5, endpos},
}
\toprule
\SetCell[r=2]{} Zone & \SetCell[c=5]{c} Training Data & & & & & \SetCell[c=5]{c} Testing Data & & & & \\
& Mean(cm) & Std(cm) & Max(cm) & Skew & Kurtosis & Mean(cm) & Std(cm) & Max(cm) & Skew & Kurtosis \\
\midrule
Zall & 44.08 & 37.44 & 373.3 & 2.48 & 9.71 & 54.23 & 41.76 & 325.1 & 2.03 & 6.19 \\
Z1 & 74.52 & 32.23 & 157.4 & -0.17 & -0.42 & 82.9 & 26.26 & 137.5 & -0.97 & 0.38 \\
Z2 & 13.20 & 10.37 & 50.80 & 1.42 & 1.34 & 12.06 & 9.91 & 53.34 & 1.95 & 4.64 \\
Z3 & 37.25 & 22.18 & 109.22 & 0.24 & -0.58 & 46.67 & 26.31 & 208 & 0.3 & -0.03 \\
Z4 & 36.05 & 16.11 & 88.9 & -0.03 & -0.37 & 40.69 & 21.48 & 78.75 & 0.13 & -1.03 \\
Z5 & 35.95 & 20.21 & 160.02 & 0.76 & 0.97 & 41.57 & 21.79 & 170.2 & 1.21 & 3.17 \\
Z6 & 59.46 & 56.26 & 373.3 & 1.60 & 2.87 & 75.05 & 58.31 & 325.1 & 1.20 & 1.52 \\
\bottomrule
\end{talltblr}
\end{sidewaystable}
\end{document}
答案2
@Celdor 答案的变体(+1):
- 除了第一列之外,其他
X
列都是用过的。这样,表格的宽度就相等\textwidth
,带有数字的列的宽度也相等。 - 第二行的文字垂直居中。
- 表体中的行成对分组(以便于阅读)。
\documentclass[twocolumn]{article}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage[version=4]{mhchem}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\begin{document}
\begin{table*}[ht]
\begin{talltblr}[
caption={Characteristics of Training and Testing Data},
label={tab:table4},
remark{Note} = {In the table Std, Max indicated standard deviation and maximum of snow depth observations in a given zone.} ]
{colspec={@{} Q[l] *{2}{X[c, si={table-format=2.2}]}
X[c, si={table-format=3.2}]
*{2}{X[c, si={table-format=-1.2}]}
*{2}{X[c, si={table-format=2.2}]}
X[c, si={table-format=3.2}]
*{2}{X[c, si={table-format=-1.2}]} @{}},
row{1,2} = {c, m, guard},
row{odd [3-Y]}={rowsep=-4pt}
}
\toprule
& \SetCell[c=5]{c} Training Data
& & & & & \SetCell[c=5]{c} Testing Data
& & & & \\
\cmidrule[r]{2-6}\cmidrule[l]{7-12}
Zone & Mean (cm) & Std (cm) & Max (cm) & Skew & Kurtosis
& Mean (cm) & Std (cm) & Max (cm) & Skew & Kurtosis \\
\midrule
Zall & 44.08 & 37.44 & 373.3 & 2.48 & 9.71
& 54.23 & 41.76 & 325.1 & 2.03 & 6.19 \\
Z1 & 74.52 & 32.23 & 157.4 & -0.17 & -0.42
& 82.9 & 26.26 & 137.5 & -0.97 & 0.38 \\
Z2 & 13.20 & 10.37 & 50.80 & 1.42 & 1.34
& 12.06 & 9.91 & 53.34 & 1.95 & 4.64 \\
Z3 & 37.25 & 22.18 & 109.22 & 0.24 & -0.58
& 46.67 & 26.31 & 208 & 0.3 & -0.03 \\
Z4 & 36.05 & 16.11 & 88.9 & -0.03 & -0.37
& 40.69 & 21.48 & 78.75 & 0.13 & -1.03 \\
Z5 & 35.95 & 20.21 & 160.02 & 0.76 & 0.97
& 41.57 & 21.79 & 170.2 & 1.21 & 3.17 \\
Z6 & 59.46 & 56.26 & 373.3 & 1.60 & 2.87
& 75.05 & 58.31 & 325.1 & 1.20 & 1.52 \\
\bottomrule
\end{talltblr}
\end {table*}
\end{document}