我想用点填充表格中相邻列条目之间的空间。到目前为止,我的方法是使用\dotfill& \dotfill
:
\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{bm}
\begin{document}
\begin{table}[]
\begin{tabular}{l@{}r}
\toprule
Symbol & Description \\
\midrule
$a$\dotfill&\dotfill scalar \\
$\bm{v}$\dotfill&\dotfill vector \\
$||\bm{v}||$\dotfill&\dotfill $l_2$ norm of vector $\bm{v}$ \\
$\langle \bm{v} \bm{u} \rangle$\dotfill&\dotfill inner product of vectors $\bm{v}$ and $\bm{u}$ \\
$\bm{A}$\dotfill&\dotfill matrix or higher order tensor \\
$\bm{A}^\top$\dotfill&\dotfill transpose of matrix $\bm{A}$ \\
$\bm{A}^{-1}$\dotfill&\dotfill inverse of matrix $\bm{A}$\\
$\bm{v_i}$\dotfill&\dotfill $i$th vector \\
$\bm{v}_i$\dotfill&\dotfill $i$th entry of vector $\bm{v}$ \\
$\bm{A}_{ij}$\dotfill&\dotfill entry at height $i$ and width $j$ of matrix $\bm{A}$ \\
$\bm{T}_{ijk}$\dotfill&\dotfill entry at height $i$, width $j$ and depth $k$ of order three tensor $\bm{T}$ \\
$M$\dotfill&\dotfill set\\
$\mathbf{X}$\dotfill&\dotfill random variable\\
$x \sim \mathbf{X}$\dotfill&\dotfill $x$ is distribited according to $\mathbf{X}$\\
$\Pr_\mathbf{X}(x)$\dotfill&\dotfill probability of event $\mathbf{X} = x$\\
$\nabla f$\dotfill&\dotfill gradient of function $f$\\
$\theta$\dotfill&\dotfill set of hyper parameters of a model\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
但这并不完全有效,因为列分隔符所在的虚线有间隙:
我研究过类似的问题,例如:
但对于我的表结构来说,答案似乎过于复杂。
对于像这样的简单表格,有没有更好的解决方案?
答案1
好的,这里有一个解决方案,它使用 ,\dotfill
同时避免在某些点行中产生难看的间隙。解决方案在于将整个tabular
结构转换为单列,并将所有 17 个 实例替换\dotfill&\dotfill
为\dotfill
。
在下面的代码中,我使用了tabularx
环境并将其宽度设置为\textwidth
。
\documentclass{article}
\usepackage{tabularx,booktabs,mathtools,bm}
\begin{document}
\begin{table}
\begin{tabularx}{\textwidth}{@{}X@{}}
\toprule
Symbol \hfill Description \\
\midrule
$a$ \dotfill scalar \\
$\bm{v}$ \dotfill vector \\
$\lVert\bm{v}\rVert$ \dotfill $l_2$ norm of vector $\bm{v}$ \\
$\langle \bm{v}, \bm{u} \rangle$ \dotfill inner product of vectors $\bm{v}$ and $\bm{u}$ \\
$\bm{A}$ \dotfill matrix or higher order tensor \\
$\bm{A}^\top$ \dotfill transpose of matrix $\bm{A}$ \\
$\bm{A}^{-1}$ \dotfill inverse of matrix $\bm{A}$\\
$\bm{v_i}$ \dotfill $i$th vector \\
$\bm{v}_i$ \dotfill $i$th entry of vector $\bm{v}$ \\
$\bm{A}_{ij}$ \dotfill entry at height $i$ and width $j$ of matrix $\bm{A}$ \\
$\bm{T}_{ijk}$ \dotfill entry at height $i$, width $j$ and depth $k$ of order three tensor $\bm{T}$ \\
$M$ \dotfill set\\
$\mathbf{X}$ \dotfill random variable\\
$x \sim \mathbf{X}$ \dotfill $x$ is distribited according to $\mathbf{X}$\\
$\Pr_\mathbf{X}(x)$ \dotfill probability of event $\mathbf{X} = x$\\
$\nabla f$ \dotfill gradient of function $f$\\
$\theta$ \dotfill set of hyper parameters of a model\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
答案2
就我个人而言,我觉得你截图中显示的布局很难让人认真对待。无论两列的点之间是否有微小的间隙,情况都是如此。对我来说,点的激增几乎就像大声喊叫:“看,妈妈,我已经想出了如何排版一排很多点!” 你的母亲可能很想表达她的爱、钦佩和无条件的支持,但其他读者通常很难认真对待这样的视觉展示。
考虑到两列宽度的差异,第一列比第二列窄得多,我认为将两列都左对齐并避免使用任何\hdotfill
指令没有任何问题。为了创造一些(有意义的)视觉效果,可以考虑每隔 5 行左右添加一些额外的垂直空白。
\documentclass{article}
\usepackage{tabularx,booktabs,mathtools,bm}
\newcolumntype{L}{>{$}l<{$}} % left aligned and automatic math mode
\begin{document}
\begin{table}[]
\centering
\begin{tabular}{@{}Ll@{}}
\toprule
$Symbol$ & Description \\
\midrule
a
& scalar \\
\bm{v}
& vector \\
\lVert\bm{v}\rVert
& $l_2$ norm of vector $\bm{v}$ \\
\langle \bm{v},\bm{u} \rangle
& inner product of vectors $\bm{v}$ and $\bm{u}$ \\
\bm{A}
& matrix or higher order tensor \\
\addlinespace
\bm{A}^\top
& transpose of matrix $\bm{A}$ \\
\bm{A}^{-1}
& inverse of matrix $\bm{A}$\\
\bm{v_i}
& $i$th vector \\
\bm{v}_i
& $i$th entry of vector $\bm{v}$ \\
\bm{A}_{ij}
& entry at height $i$ and width $j$ of matrix $\bm{A}$ \\
\addlinespace
\bm{T}_{ijk}
& entry at height $i$, width $j$ and depth $k$ of order-three tensor $\bm{T}$ \\
M
& set\\
\mathbf{X}
& random variable\\
x\sim\mathbf{X}
& $x$ is distributed according to $\mathbf{X}$\\
\Pr_{\mathbf{X}}(x)
& probability of event $\mathbf{X} = x$\\
\addlinespace
\nabla f
& gradient of function $f$\\
\theta
& set of hyperparameters of a model\\
\bottomrule
\end{tabular}
\end{table}
\end{document}