Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I’m using the titletoc package to create a TOC. How can I make sure that my dotted lines always touch the number? More precisely, I want the dotted lines to look as in the following image:

enter image description here

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

Here's one possible solution using \contentsmargin and \dottedcontents:

\documentclass{article}
\usepackage{titletoc}

\contentsmargin{0pt}
\renewcommand\contentspage{\thecontentspage}

\dottedcontents{section}[2.3em]{}{2.3em}{5pt}
\dottedcontents{subsection}[5.5em]{}{3.2em}{5pt}

\begin{document}

\tableofcontents
\section{test test test test test test}
\subsection{test}

\newpage
\setcounter{page}{12}
\section{test}
\subsection{test}

\end{document}

And the obtained ToC:

enter image description here

Personally, I don't like much this layout, and would prefer some uniform white space between the rightmost dot and the page numbers.

share|improve this answer
2  
+1 for the very diplomatic "but that's ugly" –  Brent.Longborough Mar 16 '12 at 8:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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