带括号的 dcolumn

带括号的 dcolumn

我使用 dcolumn 将单元格对齐到小数点。但是,如果使用括号,我的主文档中总是会出现溢出错误。如果我复制带有完整前导码的 MWE,就不会再出现溢出错误(TexStudio),但问题仍然存在\overfullrule=1mm

我的问题如下:

如果包含括号中的值,哪种方法可以实现小数点对齐?理想情况下,列之间的垂直空间应该是均匀的,如第一个示例所示,但没有过满的空间。

梅威瑟:

\documentclass[a4paper, 12pt, headsepline, headings=small,]{scrreprt}
\overfullrule=1mm
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amssymb, mathtools}
\usepackage{mathptmx}
\usepackage[a4paper,showframe]{geometry}
\geometry{left=2cm,right=5cm,top=2cm,bottom=2cm}
\usepackage{booktabs}

\usepackage{dcolumn}
\newcolumntype{N}{D..{2.2}} 
\newcolumntype{Z}{D..{1.2}} 

\begin{document}


\begin{table}[t]
\caption{caption x}
%\setlength{\tabcolsep}{-1.5pt} % general space between cols (6pt standard)
\begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}ZNNNNN}
\toprule 
& \multicolumn{1}{r}{Const term} & \multicolumn{1}{c}{$xcvb^e$} & 
\multicolumn{1}{c}{$xcvb$} & \multicolumn{1}{c}{$xcvb$} & \multicolumn{1}{c}{$xcvb$} & 
\multicolumn{1}{c}{$xcvb$ add a} \\
\midrule 
\multicolumn{1}{l}{$xcvb^e$} & 4.12 & 4.12 & 4.12 & -8.97 & -8.97 & -12.98 \\
& (3.54) & (1.95) & (0.64) & (-0.73) & (-1.57) & \\[6pt]
\multicolumn{1}{l}{$xcvb$} & 0.02 & -0.27 & 0.88 & -0.04 & 0.13 & -12.98 \\
& (3.35) & (-0.12) & (-0.12) & (-0.12) & (-0.12) & \\[6pt]
\multicolumn{1}{l}{$xcvb$} & 0.03 & 0.46 & -0.00 & 0.99 & -0.00 & -12.98 \\
& (1.35) & (22.38) & (22.38) & (22.38) & (22.38) & \\[6pt]
\multicolumn{1}{l}{$xcvb$} & 0.07 & -0.03 & -0.00 & 0.01 & 0.93 & -12.98 \\
& (2.63) & (-0.55) & (41.45) & (88.34) & (88.88) & \\
\bottomrule
\end{tabular*}
\end{table}



\end{document}

谢谢。

答案1

1只需在小数点前后增加小数说明符,即可为括号添加一个额外的位置:

示例输出

\documentclass[a4paper, 12pt, headsepline, headings=small,]{scrreprt}
\overfullrule=1mm
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{booktabs}

\usepackage{dcolumn}
\newcolumntype{N}{D..{3.3}} 
\newcolumntype{Z}{D..{2.3}} 

\begin{document}

\begin{table}[t]
\caption{caption x}
\begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}ZNNNNN}
\toprule 
& \multicolumn{1}{r}{Const term} & \multicolumn{1}{c}{$xcvb^e$} & 
\multicolumn{1}{c}{$xcvb$} & \multicolumn{1}{c}{$xcvb$} &
\multicolumn{1}{c}{$xcvb$} & \multicolumn{1}{c}{$xcvb$ add a} \\
\midrule 
\multicolumn{1}{l}{$xcvb^e$} & 4.12 & 4.12 & 4.12 & -8.97 & -8.97 & -12.98 \\
& (3.54) & (1.95) & (0.64) & (-0.73) & (-1.57) & \\[6pt]
\multicolumn{1}{l}{$xcvb$} & 0.02 & -0.27 & 0.88 & -0.04 & 0.13 & -12.98 \\
& (3.35) & (-0.12) & (-0.12) & (-0.12) & (-0.12) & \\[6pt]
\multicolumn{1}{l}{$xcvb$} & 0.03 & 0.46 & -0.00 & 0.99 & -0.00 & -12.98 \\
& (1.35) & (22.38) & (22.38) & (22.38) & (22.38) & \\[6pt]
\multicolumn{1}{l}{$xcvb$} & 0.07 & -0.03 & -0.00 & 0.01 & 0.93 & -12.98 \\
& (2.63) & (-0.55) & (41.45) & (88.34) & (88.88) & \\
\bottomrule
\end{tabular*}
\end{table}

\end{document}

相关内容