答案1
你可以这样做siunitx
:
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\begin{tabular}{
S[table-format=2.2]
S[table-format=2.2,table-space-text-pre={[},table-space-text-post={]},
table-align-text-pre=false,table-align-text-post=false]
}
0 & [0] \\
1.23 & [1.23] \\
12.34 & [12.34]
\end{tabular}
\end{document}
答案2
您可以使其]
动作类似.
并强制对齐点,将其重新插入到正确的位置。
\documentclass{article}
\usepackage{dcolumn}
\makeatletter
\def\DC@centre#1#2#3{%
\let\DC@end\DC@endcentre
\uppercase{\def~}{$\egroup\setbox\tw@=\hbox\bgroup${#2}}%
\uccode`\~=`\]%
\uppercase{\def~}{$\egroup\setbox\tw@=\hbox\bgroup${]}}%
\setbox\tw@=\hbox{${\phantom{{#2}}}$}%
\setbox\z@=\hbox\bgroup$\mathcode`#1="8000
\mathcode`]="8000 }
\begin{document}
\begin{tabular}{D{.}{.}{-1}}
[0]\\\relax
[1.23]\\\relax
[12.34]
\end{tabular}
\end{document}