add tag
निरंजन
I am trying to emulate the visual output of `l3doc` for printing glossaries. I am trying to avoid additional packages. I am fairly successful in creating what I want. This is a short MWE:

```
\documentclass{article}
\usepackage{multicol}

\begin{document}
\setlength\parindent{0pt}
\begin{multicols}{2}
  \raggedleft
  \textsc{abc}: a big cat\quad\dotfill\quad 1, 2, 3\par
  \textsc{abc}: a big cat\quad\dotfill\quad 1, 2, 3\par
  \textsc{abc}: a big cat\quad\dotfill\quad 1, 2, 3\par
  \textsc{abc}: a big cat\quad\dotfill\quad 1, 2, 3\par
  \textsc{abc}: a big cat\quad\dotfill\quad 1, 2, 3\par
  \textsc{abc}: a big cat\quad\dotfill\quad 1, 2, 3\par
  \textsc{abc}: a big cat\quad\dotfill\quad 1, 2, 3\par
  \textsc{abc}: a big cat\quad\dotfill\quad 1, 2, 3\par
\end{multicols}
\end{document}
```

![image.png](/image?hash=0da195650154748b2d4d9dab7074d8a937fc0ed005cdba45bfa7d5aea0cd1706)

A small problem I would love to fix is when the list of page numbers become slightly longer, e.g., if I add another line `\textsc{abc}: a big cat\quad\dotfill\quad 1, 2, 3, 4, 5, 6, 7, 8, 9, 10`, the output is:

![image.png](/image?hash=f791d456c2560d5296bd0ad81d1d3f1e57af42237d2786673b847559980ae14c)

Honestly, this is not bad either, but as an improvement I would have loved to add, say 0.5cm dotfill in the last line too. Basically something like a minimum width for dotfill. I don't mind if the line breaks after first two three numbers and the remaining ones are pushed to the next line. That is okay. But there should be some dots at least. Is it doable?
Top Answer
Skillmon
Taking a look at how `\dotfill` is actually defined will help us understand how relatively simple this task really is:

```
\dotfill :
macro:->\leavevmode \cleaders \hb@xt@ .44em{\hss .\hss }\hfill \kern \z@
```

Let's break this apart a bit:

- `\leavevmode` should be rather obvious, we want to do something in the horizontal direction, so no vertical mode!

- `\cleaders` is an interesting primitive. This here is the short description provided in TeXbyTopic:
    > `\leaders` Fill a specified amount of space with a rule or copies of box.
    > `\cleaders` Like `\leaders`, but with box leaders any excess space is split equally before and after the leaders.
   So we get a primitive that will as following object take either a `\vrule`/`\hrule` primitive, or a box (`\hbox`?!) and repeat that object for as much space as a following space-skipping command will take.
   
- `\hb@xt@` oh, a horizontal box, this one will have a width of `.44em`.

- `\hss` infinitely stretchable/shrinkable horizontal space (will, in addition with the second `\hss` centre the `.` inside the box -- this is basically the same as saying `\makebox[.44em][c]{.}` in LaTeX syntax)

- `\hfill` oh, a horizontal space-skipping command (second order infinitely stretchable space, at least 0pt)

- `\kern\z@` a kern of zero width to prevent TeX from unskipping the previous `\hfill`


So all we have to do is use another skip-size than `\hfill`, one that might stretch into infinity, but covers at least 0.5cm: `\hskip 0.5cm plus 1fill`.

With that out of the way we can define our ultimate `\quackfill`:

```
\documentclass{article}
\usepackage{multicol}

\newcommand\quackfill
  {%
    \leavevmode
    \quad
    \cleaders
      \hbox to .44em{\hss.\hss}%
      \hskip 0.5cm plus 1fill\relax
    \quad
    \kern0pt %<- protect the `\quad`
  }

\begin{document}
\setlength\parindent{0pt}
\begin{multicols}{2}
  \raggedleft
  \textsc{abc}: a big cat\quackfill 1, 2, 3\par
  \textsc{abc}: a big cat\quackfill 1, 2, 3\par
  \textsc{abc}: a big cat\quackfill 1, 2, 3\par
  \textsc{abc}: a big cat\quackfill 1, 2, 3\par
  \textsc{abc}: a big cat\quackfill 1, 2, 3\par
  \textsc{abc}: a big cat\quackfill 1, 2, 3\par
  \textsc{abc}: a big cat\quackfill 1, 2, 3\par
  \textsc{abc}: a big cat\quackfill 1, 2, 3, 4, 5, 6, 7, 8, 9, 10\par
\end{multicols}
\end{document}
```

![foo.png](/image?hash=cd5742c676856362ac20b4516bf616c49dccf12b26cfa3bbd0ce0305c2762274)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.