# Fill space between entries in adjacent columns of table with dots

I would like to fill the space between entries of adjacent column in a table with dots. My approach so far is to use \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}


But this does not work entirely, as there gaps in the dotted line where the column seperator is located:

I looked into similar questions, like this one:

Fill space with dots within table

But the answers seem overly complicated for my table structure.

Is there a better solution for a simple table like this?

• Could you make your scripts compilable? – Raaja Aug 5 '19 at 4:51
• Ah, I forgot about my macros. One moment please. – lo tolmencre Aug 5 '19 at 4:53
• @Raaja ok, done. – lo tolmencre Aug 5 '19 at 4:58
• I still do not see how this snippet can be compiled. Please make a MWE. – Raaja Aug 5 '19 at 4:59
• @Raaja ok, added includes. If you meant that. – lo tolmencre Aug 5 '19 at 5:00

Speaking for myself, I find the layout shown in your screenshot hard to take seriously. This is irrespective of whether or not there's a slight gap between the dots of the two columns. For me, the proliferation of dots comes perilously close to shouting out loud, "Look, Ma, I've figured out how to typeset lots of dots in a row!" Your mother may well be inclined to express her love, admiration, and unconditional support, but other readers generally find it difficult to take such visual displays seriously.

Given the disparity in the widths of the two columns, with the first column being much narrower than the second, I can see nothing wrong with making both columns left-aligned -- and refraining from using any \hdotfill directives. To create some (meaningful) visual interest, consider adding a bit of extra vertical whitespace after every 5 rows or so.

\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  \\
\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}$  \\
\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$\\
\nabla f
& gradient of function $f$\\
\theta
& set of hyperparameters of a model\\
\bottomrule
\end{tabular}
\end{table}
\end{document}


Ok, here's a solution that uses \dotfill while avoiding the problem of creating an unsightly gap in some of the rows of dots. The solution lies in converting the entire tabular structure to having a single column and replacing all 17 instances of \dotfill&\dotfill to just \dotfill.

In the following code, I've employed a tabularx environment and set its width to \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}