2

I would like to create to create list with dot leaders.Each entry into the list essentially contains four parts: a number, a description, dot leaders and lastly another number. I want it to look like the following:enter image description here . I have looked at various examples on this forum but most of the examples do not give me exactly what I want-the most common problem is that when the description is long it starts from extreme left of the next line. The list I am trying to generate is very similar to a table of contents.

1
  • What is that last number? Are you trying to produce a list of examples? Then how is the examples environment defined?
    – user11232
    Apr 3 '15 at 4:12
3

(Encountered this question while searching for something else. In case there's still any interest in the answer…)

Exactly this problem is discussed in A Beginner's Book of TeX by Seroul and Levy, on page 48. (Having leaders, but without the long line overlapping into the page number area.) Their trick is to make the line narrower on the right, then typeset the page numbers beyond the end of that line using \rlap. So, a minor modification of Werner's answer:

\documentclass{article}
\begin{document}

\newcommand{\page}[1]{\rightskip=25pt \dotfill\rlap{\hbox to 25pt{\hfill#1}}\par}

\begin{itemize}
  \item[2.1] An example \page{21}
  \item[2.2] A longer example like this such that the line wraps down to the
    next line and the last entry gets wrapped to the next line \page{22}
  \item[2.31] Another example \page{132}
\end{itemize}

\end{document}

which produces:

Screenshot from PDF output

1

Perhaps it suffices to create a visually-equivalent ToC. Dot leaders can be achieved using \dotfill:

enter image description here

\documentclass{article}
\begin{document}

\begin{itemize}
  \item[2.1] An example \dotfill 21
  \item[2.2] A longer example like this such that the line wraps down to the 
    next line and the last entry gets wrapped to the next line \dotfill 22
  \item[2.31] Another example \dotfill 132
\end{itemize}

\end{document}
2
  • the long line should really not overlap the page number. Apr 3 '15 at 12:46
  • Is there a way to do this without the long line overlapping coming below the entry 21?
    – ecuser
    Apr 4 '15 at 5:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.