我正在使用NiceTabular
来自包的环境nicematrix
和S
来自包的 -type 列制作表格siunitx
。这些表格有多行侧标题。根据表格组合指南,数字必须在单元格中垂直居中或底部对齐(A. Wolański,Edycja Tekstów):
这是通过使用m
-type 列作为侧标题来完成的,这是@Werner 建议的这里。此外,在侧标题有多行单元格的情况下,需要缩进除第一行之外的所有行:
如何修改代码来实现此效果?我尝试应用给出的解决方案这里,但没有成功。如何强制m
-type 列中的文本左对齐?
代码:
\documentclass{standalone}
\usepackage{nicematrix} % for NiceTabular environment
\usepackage{siunitx} % for proper horizontal alignments of numbers
\usepackage{booktabs} % for commands \toprule, \midrule, \bottomrule
\begin{document}
\begin{NiceTabular}{
>{\setlength{\parindent}{-1em}}m{2cm}
S[table-format=2.2]
S[table-format=3.1]
}
\toprule
\multicolumn{1}{c}{First descr.} & \multicolumn{1}{c}{Second descr.} & \multicolumn{1}{c}{Third descr.}\\
\midrule
Long first side heading & 1.1 & 11.1\\
Also long second side heading & 11.11 & 111.1\\
\bottomrule
\end{NiceTabular}
\end{document}
答案1
使用@Fran 评论和关于单元格右侧文本不整齐的答案我有:
\documentclass{standalone}
\usepackage{nicematrix} % for NiceTabular environment
\usepackage{siunitx} % for proper horizontal alignments of numbers
\usepackage{booktabs} % for commands \toprule, \midrule, \bottomrule
\usepackage{ragged2e} % for ragged right text
\begin{document}
\begin{NiceTabular}{
>{\RaggedRight\arraybackslash\hangindent1em}m{3.5cm}
S[table-format=2.2]
S[table-format=3.1]
}
\toprule
\multicolumn{1}{c}{First descr.} & \multicolumn{1}{c}{Second descr.} & \multicolumn{1}{c}{Third descr.}\\
\midrule
Long text in the first side heading cell & 1.1 & 11.1\\
Also long text in the second side heading cell & 11.11 & 111.1\\
\bottomrule
\end{NiceTabular}
\end{document}