我想创建一个带有换行符的描述的表格。不幸的是,有一个标题没有显示,我不知道为什么以及如何解决它。我的代码如下:
\documentclass{article}
\usepackage{rotating}
\usepackage{makecell}
\usepackage{tabularray}
\begin{document}
\begin{table}
\footnotesize
\begin{tblr}{colspec={cQ[c,3cm]Q[c,3cm]Q[c,3cm]Q[c,3cm]}}
& \SetCell[c=2]{c} {Chlorination degree of \\ paraffinic compounds $n$\textsubscript{Cl}} & \SetCell[c=2]{c} {Chlorination degree of \\ olefinic compounds $n$\textsubscript{Cl}}\\
& non-exposed (0h) & exposed (144h) & non-exposed (0h) & exposed (144h) \\
Non-hydroxylated & 8.80 $\pm$ 0.00 & 9.07 $\pm$ 0.00 & 8.37 $\pm$ 0.02 & 8.55 $\pm$ 0.01 \\
Mono-hydroxylated & 8.31 $\pm$ 0.06 a) & 7.59 $\pm$ 0.01 & 8.31 $\pm$ 0.06 a) & 7.04 $\pm$ 0.03 \\
Di-hydroxylated & n.d. & 6.61 $\pm$ 0.04 & n.d. & 5.23 $\pm$ 0.01 \\
\end{tblr}
\end{table}
\end{document}
输出如下:
如您所见,缺少最后两列的描述。它应该是这样的:
答案1
与tabularray
其他表格相反,每行中的包无论是否为多列单元格(写为\SetCell[c=2]{c} ...
),都必须按照表格序言中的定义全部为 & 符号。对于您来说,MWE 应该是:
\documentclass{article}
\usepackage{rotating}
\usepackage{makecell}
\usepackage{tabularray}
\usepackage[version=4]{mhchem} % <--- new
\begin{document}
\begin{table}
\footnotesize
\begin{tblr}{colspec={c *{4}{Q[c,3cm]}}}
& \SetCell[c=2]{c} {Chlorination degree of \\
paraffinic compounds $n_{\ce{Cl}}$}
& & \SetCell[c=2]{c} {Chlorination degree of \\
olefinic compounds $n_{\ce{Cl}}$}
& \\
& non-exposed (0h)
& exposed (144h)
& non-exposed (0h)
& exposed (144h) \\
Non-hydroxylated
& $8.80\pm 0.00$
& $9.07\pm 0.00$
& $8.37\pm 0.02$
& $8.55\pm 0.01$ \\
Mono-hydroxylated
& $8.31\pm 0.06$ a)
& $7.59\pm 0.01$
& $8.31\pm 0.06$ a)
& $7.04\pm 0.03$ \\
Di-hydroxylated
& n.d.
& $6.61\pm 0.04$
& n.d.
& $5.23\pm 0.01$ \\
\end{tblr}
\end{table}
\end{document}
编辑:
对于化学元素(和化学式),使用包装并写出氯或 n-氯mhchem
的符号是明智的。\ce{Cl}
$n_{\ce{Cl}}$
无关:您的表格比文本区域宽度宽。因此,您可以考虑以下表格序言:
\begin{tblr}{colspec={l *{4}{X[c]}}}
这使:
答案2
你需要 tabularray
tabular*
? 使用标准和可以获得更好的结果siunitx
。
\documentclass{article}
\usepackage{booktabs,siunitx}
\usepackage[version=4]{mhchem}
\sisetup{
retain-zero-uncertainty,
uncertainty-mode=separate,
}
\begin{document}
\begin{table}
\centering
\setlength{\tabcolsep}{0pt}
\newcommand{\splitcell}[2]{%
\multicolumn{#1}{c}{\begin{tabular}{@{}c@{}}#2\end{tabular}}%
}
\newcommand{\?}[1]{\rlap{\textsuperscript{#1}}}
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}}
l
S[table-format=1.2(2)]
S[table-format=1.2(2)]
S[table-format=1.2(2)]
S[table-format=1.2(2)]
@{}
}
\toprule
& \splitcell{2}{Chlorination degree of \\ paraffinic compounds $n_{\ce{Cl}}$}
& \splitcell{2}{Chlorination degree of \\ olefinic compounds $n_{\ce{Cl}}$} \\
\cmidrule{2-3} \cmidrule{4-5}
& {non-exposed} & {exposed} & {non-exposed} & {exposed} \\
& {(0h)} & {(144h)} & {(0h)} & {(144h)} \\
\midrule
Non-hydroxylated & 8.80 \pm 0.00 & 9.07 \pm 0.00 & 8.37 \pm 0.02 & 8.55 \pm 0.01 \\
Mono-hydroxylated & 8.31 \pm 0.06\?{a} & 7.59 \pm 0.01 & 8.31 \pm 0.06\?{a} & 7.04 \pm 0.03 \\
Di-hydroxylated & {n.d.} & 6.61 \pm 0.04 & {n.d.} & 5.23 \pm 0.01 \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}