1

I'm working on a proposal with a strict character limit. I expect the funding agency will compute the character count in my document by simply extracting the text from my PDF. The problem is that the dot leaders in my table of contents are eating up a good chunk of my character count.

I don't want to alter the layout of my table of contents too drastically, since what LaTeX provides as a default already looks very nice with my document style. (For example, I think the style favoured by Robert Bringhurst or the ones featured in the answers to this question wouldn't fit well.) Would it be possible to simply replace the character-based dot leaders in the table of contents with a graphical dotted or dashed line, such that the dots/dashes are aligned from line to line? Maybe even a solid rule would work in my case if there is no easy solution.

3 Answers 3

1

Assuming you're using a standard document class (or any other one using the standard definition of \@dottedtocline to create your TOC), the following switches out the periods with tiny squares.

\documentclass[]{article}

\usepackage{etoolbox}

\makeatletter
\patchcmd\@dottedtocline{\hbox{.}}{\rule{.23ex}{.23ex}}{}{}
\makeatother

\usepackage{duckuments}

\begin{document}
\duckument[toc]
\end{document}

Original looks with periods:

enter image description here

New looks with tiny squares:

enter image description here

4
  • This works but for some reason the rendering of the tiny squares is very ugly in my PDF viewer (Okular). The problem doesn't happen with my tikz solution from another answer.
    – Psychonaut
    Sep 16, 2020 at 13:56
  • @Psychonaut I'm not responsible of the shortcomings of your PDF-viewer. My viewer doesn't have said problem. Try to zoom in a bit.
    – Skillmon
    Sep 16, 2020 at 13:58
  • I know; I'm not trying to lay the blame on you. :) That said, the problem persists even when I zoom in.
    – Psychonaut
    Sep 16, 2020 at 14:01
  • @Psychonaut that's strange. Well taking a look at the printouts might help then :)
    – Skillmon
    Sep 16, 2020 at 14:07
0

Here is one solution I've just come up with:

\usepackage{tocloft}
\usepackage{tikz}
\renewcommand{\cftdot}{\begin{tikzpicture}\node [circle,fill,inner sep=0.54pt]{};\end{tikzpicture}}

I'm not sure how optimal this is (and of course the size of the dots is hard-coded rather than being scaled to the text size) so I'd be happy to hear of any different or better solutions.

1
  • 1
    You could use ex as the unit for your dimensions, that would be font dependent.
    – Skillmon
    Sep 16, 2020 at 17:17
0

One possibility is to use em-dashes instead of periods as the dots.

% dottedprob.tex  SE 562961
\documentclass{article}
\usepackage{tikz}
\usepackage{tocloft}
\renewcommand{\cftdot}{---}
% following is from the OP
%\renewcommand{\cftdot}{\begin{tikzpicture}\node [circle,fill,inner sep=0.54pt]{};\end{tikzpicture}}

\begin{document}
\tableofcontents
\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}

\end{document}

Or you could try 2em-dashes (\renewcommand{\cftdot}{------}).

But I think that your solution looks good and you could always tweak it depending on the documents default font size.

1
  • I'm afraid this isn't much of a solution, as the em dashes are still rendered in the PDF as text that gets included in the character count. The dashes are wider than the periods, so there are fewer of them, but in a long table of contents there can still be hundreds.
    – Psychonaut
    Sep 16, 2020 at 17:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .