我想\dotfill
在某个环境中使用虚线(通过命令或等效命令)tabular*
,以便在两列之间的空间中也有点(如下图中的红点),但我无法管理它。
以下是 MWE(有一些不成功的尝试):
\documentclass{article}
\usepackage{array, booktabs}
\makeatletter
\newcommand\pfill{\leavevmode\leaders\hb@[email protected]{\hss.\hss}\hfill\kern\z@}
\makeatother
\begin{document}
\begin{tabular*}{0.6\textwidth}{@{\hspace{\tabcolsep}\extracolsep{\fill}} l<{\pfill} c}\toprule
Blah blah blah & 123 \\
Blah blah blah blah blah & 123456\\
Blah blah & 123456789\\\bottomrule
\end{tabular*}
%\begin{tabular*}{0.6\textwidth}{@{\hspace{\tabcolsep}\extracolsep{\fill}} l<{\pfill} @{\pfill} c}\toprule% Does not work
% Blah blah blah & 123 \\
% Blah blah blah blah blah & 123456\\
% Blah blah & 123456789\\\bottomrule
%\end{tabular*}
%\begin{tabular*}{0.6\textwidth}{@{\hspace{\tabcolsep}\extracolsep{\pfill}} l<{\pfill} c}\toprule% Does not work
% Blah blah blah & 123 \\
% Blah blah blah blah blah & 123456\\
% Blah blah & 123456789\\\bottomrule
%\end{tabular*}
\end{document}
答案1
带包装nicematrix
\documentclass{article}
\usepackage{array, booktabs}
\usepackage{nicematrix}
\makeatletter
\newcommand\pfill{\leavevmode\leaders\hb@[email protected]{\hss.\hss}\hfill\kern\z@}
\makeatletter
\begin{document}
\begin{NiceTabularX}{0.6\textwidth}{X<{\pfill}@{}c}
\toprule
Blah blah blah & 123 \\
Blah blah blah blah blah & 123456 \\
Blah blah & 123456789 \\
\bottomrule
\end{NiceTabularX}
\bigskip
\begin{NiceTabularX}{0.6\textwidth}{X[2]<{\pfill}@{\makebox[0.6em][c]{\textcolor{red}{.}}}>{\pfill}X}
\toprule
Blah blah blah & 123 \\
Blah blah blah blah blah & 123456 \\
Blah blah & 123456789 \\
\bottomrule
\end{NiceTabularX}
\end{document}