TeX - LaTeX Asked on February 23, 2021
I am typesetting a book and am using dotfill
to produce a sequence of dots extending to the displayed page number in the Table of Contents.
Alas, with the following (MWE) code
documentclass[12pt]{book}
usepackage{tocloft}
begin{document}
chapter*{textbf{TRANSLATOR'S PREFACE}}
addcontentsline{toc}{chapter}{textbf{Translator's Preface dotfill}}
newpage
tableofcontents
end{document}
I produce the following output:
Can somebody help me to remedy this so that the dots extend all the way to the page number as usual?
This happens because tocloft
already inserts a leader as part of setting a chapter in the ToC; it's just a blank leader (or hfill
). And, butting these leaders together (a dotfill
and hfill
) just makes them share the distance between the end points. That's why your leader - dotfill
- goes only half-way.
Remedy this by specifying the appropriate chapter
leader using tocloft
's style:
renewcommand{cftchapleader}{dotfill}
Remember to remove the dotfill
from your addcontentsline
insertion.
If you want it bold you can use:
renewcommand{cftchapleader{bfseries dotfill}}
Correct answer by Werner on February 23, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP