我有一张表,我想使用 Bigdelim 包关联一些条目。但是,我不知道如何让分隔符对齐。我有一张表,碰巧每个单元格都有相同的条目,因此分隔符排列得很好:
我目前的代码如下所示:
\documentclass{report} % use "amsart" instead of "article" for AMSLaTeX format
\usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots.
\usepackage[utf8]{inputenc}
%Maths
\usepackage{amssymb}
% Chemistry packages
\usepackage{chemmacros}
\chemsetup{formula=mhchem}
% Table settings
\usepackage{array}
\renewcommand{\arraystretch}{1.5}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\usepackage{dcolumn}
\newcolumntype{e}[1]{D{.}{.}{4.1}}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{booktabs}
\newcommand{\mc}{\multicolumn}
\newcommand{\mr}{\multirow}
\usepackage{bigdelim}
\begin{document}
\begin{table}[h]
\caption{Example of the issue}
\begin{tabularx}{\textwidth}{l *6{e{-2}}}
\toprule
\mc{1}{c}{\mr{2}{*}{Assignment}} & \mc{2}{c}{Exp.} & \mc{2}{c}{Column 1} & \mc{2}{c}{Column 2} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7}
& \mc{1}{Y}{\ce{\nu}} & \mc{1}{Y}{\ce{\Delta\nu}} & \mc{1}{Y}{\ce{\nu}} & \mc{1}{Y}{\ce{\Delta\nu}} & \mc{1}{Y}{\ce{\nu}} & \mc{1}{Y}{\ce{\Delta\nu}} \\
\midrule
\ldelim\{{2}{*}[\ce{2\nu2}] & & 293 & 3112 & 32.2 & 23 & 0.00 \\
& & 34 & 22.22 & 2 & 1 & 669 \\
\ldelim\{{2}{*}[\ce{\nu1}] & 231 & -1232 & 1232 & 232.2 & 0.0 & 3 \\
& & 31223 & 33.4 & -35.1 & 221.4 & -30.2 \\
\ce{\nu2} & 1.5 & +21.5 & 120.0 & +7.7 & 10.9 & +121.6 \\
\bottomrule
\end{tabularx}
\end{table}
\begin{table}[h]
\caption{Example of the ideal.}
\label{tbl:h2s-tma}
\begin{tabularx}{\textwidth}{l c *6{e{-2}}}
\toprule
\mc{2}{c}{\mr{2}{*}{Assignment}} & \mc{2}{c}{Exp.} & \mc{2}{c}{Column 1} & \mc{2}{c}{Column 2} \\
\cmidrule(lr){3-4} \cmidrule(lr){5-6} \cmidrule(lr){7-8}
& & \mc{1}{Y}{\ce{\nu}} & \mc{1}{Y}{\ce{\Delta\nu}} & \mc{1}{Y}{\ce{\nu}} & \mc{1}{Y}{\ce{\Delta\nu}} & \mc{1}{Y}{\ce{\nu}} & \mc{1}{Y}{\ce{\Delta\nu}} \\
\midrule
\mr{3}{*}{\ce{2\nu2}} & \ldelim\{{3}{*}[$A_1$] & 2 & & & & & \\
& & 241.0 & & & & & \\
& & 24 & & 2415.6 & +629 & 2.8 & +34.8 \\
\mr{2}{*}{\ce{\nu1}} & \ldelim\{{2}{*}[$A_1$] & 2324.00 & -261.3 & & & & \\
& & 234.9 & -80.1 & 24.4 & -1360.2 & 224.5 & -312.1 \\
\ce{\nu2} & $A_1$ & 12.9 & +203.9 & 155.9 & +7.6 & 1.6 & +112.3 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
有人知道我该如何垂直对齐表 1 中的括号,使它们看起来像表 2 吗?另外,有没有办法对齐所有不同的 A1?我刚注意到括号已将顶部两个推离了对齐位置……
(顺便问一下,有没有什么办法可以让括号之间的距离稍微分开一点?如果可能的话,我宁愿它们在表 2 中不要互相接触,但这只是一种风格偏好......)
答案1
具有{NiceTabular}
和的nicematrix
列(的列不受 的支持)。S
siunitx
d
dcolumn
nicematrix
在 中nicematrix
,有一个内置命令\SubMatrix
可用于绘制括号。
\documentclass{report}
\usepackage{geometry}
\usepackage{caption}
\usepackage{siunitx}
\usepackage{nicematrix}
\usepackage{booktabs}
\renewcommand{\arraystretch}{1.5}
\begin{document}
\begin{table}[h]
\caption{Example of the issue}
\begin{NiceTabular}{l *6{S}}
\toprule
\Block{2-1}{Assignment} & \Block{1-2}{Exp.} && \Block{1-2}{Column 1} && \Block{1-2}{Column 2} & \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7}
& {$\nu$} & {$\Delta\nu$} & {$\nu$} & {$\Delta\nu$} & {$\nu$} & {$\Delta\nu$} \\
\midrule
\Block{2-1}{$2\nu_2$} & & 293 & 3112 & 32.2 & 23 & 0.00 \\
& & 34 & 22.22 & 2 & 1 & 669 \\
\Block{2-1}{$\nu_1$} & 231 & -1232 & 1232 & 232.2 & 0.0 & 3 \\
& & 31223 & 33.4 & -35.1 & 221.4 & -30.2 \\
$\nu_2$ & 1.5 & +21.5 & 120.0 & +7.7 & 10.9 & +121.6 \\
\bottomrule
\CodeAfter [sub-matrix/xshift=1cm]
\SubMatrix{\{}{3-2}{4-7}{.}
\SubMatrix{\{}{5-2}{6-7}{.}
\end{NiceTabular}
\end{table}
\end{document}
与往常一样nicematrix
,您需要进行多次编译。
在 中{NiceTabular}
,无法定义同时具有X
和S
(的siunitx
)列特征的列。但是,可以使用。该环境对应于标准 LaTeX 的{NiceTabular*}
环境。{tabular*}
\documentclass{report}
\usepackage{geometry}
\usepackage{caption}
\usepackage{siunitx}
\usepackage{nicematrix}
\usepackage{booktabs}
\renewcommand{\arraystretch}{1.5}
\begin{document}
\begin{table}[h]
\caption{Example of the issue}
\begin{NiceTabular*}{\textwidth}{l@{\extracolsep{\fill}}SSSSSS}
\toprule
\Block{2-1}{Assignment} & \Block{1-2}{Exp.} && \Block{1-2}{Column 1} && \Block{1-2}{Column 2} & \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7}
& {$\nu$} & {$\Delta\nu$} & {$\nu$} & {$\Delta\nu$} & {$\nu$} & {$\Delta\nu$} \\
\midrule
\Block{2-1}{$2\nu_2$} & & 293 & 3112 & 32.2 & 23 & 0.00 \\
& & 34 & 22.22 & 2 & 1 & 669 \\
\Block{2-1}{$\nu_1$} & 231 & -1232 & 1232 & 232.2 & 0.0 & 3 \\
& & 31223 & 33.4 & -35.1 & 221.4 & -30.2 \\
$\nu_2$ & 1.5 & +21.5 & 120.0 & +7.7 & 10.9 & +121.6 \\
\bottomrule
\CodeAfter [sub-matrix/xshift=1cm]
\SubMatrix{\{}{3-2}{4-7}{.}
\SubMatrix{\{}{5-2}{6-7}{.}
\end{NiceTabular*}
\end{table}
\end{document}