
我想用點填滿表格中相鄰列條目之間的空間。到目前為止我的方法是使用\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}