7

This following question relates to the one posted here: On the Display of Long Font Size-Adjusted Subsection TOC Entries

Consider the following code which adjusts the font size of the TOC subsection entries:

\documentclass[12pt,openany]{book} \usepackage[paperwidth=4in,paperheight=6in]{geometry} \usepackage[sfdefault]{cabin} \usepackage{tocloft} \renewcommand{\cftsubsecfont}{\hskip 10pt\tiny\par} \renewcommand\cftsubsecafterpnum{\tiny\par} \begin{document} \tableofcontents \addcontentsline{toc}{subsection}{This is a very long subsection entry in the Table of Contents that will be split over multiple lines in the TOC; however, I would like to avoid the large vertical gap between the last two lines.} \end{document} 

which produces:

enter image description here

QUESTION: How may the above code be modified in order to eliminate the large gap between the last two lines in the TOC subsection entry?

Thank you.

2
  • 1
    Have you given \renewcommand\cftsubsecpagefont{\tiny} a try? Put differently, since you're using \tiny as the font size for \cftsubsecfont, why not also for \cftsubsecpagefont? Commented Feb 11 at 13:04
  • @Mico Thank you for your comment. Actually, I did have the subsection page numbers font size adjusted in the actual document; I neglected to put it in the MWE. Thank you also for your answer. (+1) Commented Feb 11 at 14:09

2 Answers 2

4

Since you're using \tiny as the font size for \cftsubsecfont, you might as well also use \tiny as the font size for \cftsubsecpagefont. And, while you're at it, you may also want to change \cftsubsecleader.

enter image description here

\documentclass[12pt,openany]{book} \usepackage[paperwidth=4in,paperheight=6in]{geometry} \usepackage[sfdefault]{cabin} \usepackage{tocloft} \usepackage{microtype} \renewcommand\cftsubsecfont{\hspace{10pt}\tiny} \renewcommand\cftsubsecafterpnum{\tiny} \renewcommand\cftsubsecpagefont{\tiny} % <-- new \renewcommand\cftsubsecleader{\tiny\cftdotfill{\cftsubsecdotsep}} % <-- new % default: \cftdotfill{\cftsubsecdotsep}, i.e., without '\tiny' \begin{document} \tableofcontents \addcontentsline{toc}{subsection}{This is a very long subsection entry in the Table of Contents that will be split over multiple lines in the TOC. However, I would like to avoid the large vertical gap between the last two lines.} \end{document} 
1
  • This answer works nicely in my actual document as it does not shift the subsection entries beyond what they were originally. Thank you. Commented Feb 11 at 14:21
6

You need to typeset the page number in a zero height box. For this, you can try to add \smash at the end of \cftsubsecpagefont

\renewcommand{\cftsubsecpagefont}{\smash} 

Example:

\documentclass[12pt,openany]{book} \usepackage[paperwidth=4in,paperheight=6in]{geometry} \usepackage[sfdefault]{cabin} \usepackage{tocloft} \renewcommand{\cftsubsecfont}{\hskip 10pt\tiny\par} \renewcommand{\cftsubsecpagefont}{\smash} \renewcommand\cftsubsecafterpnum{\tiny\par} \begin{document} \tableofcontents \addcontentsline{toc}{subsection}{This is a very long subsection entry in the Table of Contents that will be split over multiple lines in the TOC; however, I would like to avoid the large vertical gap between the last two lines.} \end{document} 

Example

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.