Subsection title runs over end of last dot in TOC

Issue #179 closed
Fabian Schiemenz created an issue

I am using classicthesis for my document. The TOC however has issues for some subsections, as they run out of the dotted lines.

How can this be fixed? If reducing the inter-word spacing is possible then this would be the best option if it runs over by 1 char or so, otherwise also a linebreak is fine...

Official response

  • André Miede repo owner

    Thanks for your answers, I’ll quote Fabian’s reply here so I can pin it to the top:

    Hyphen penalties also change nothing, however I got some improvement by using

    %Reduce TOC space after section and subsection number
    \addtolength{\cftsecnumwidth}{-1mm}
    \addtolength{\cftsubsecnumwidth}{-1mm}
    
    %Force a minimum number of dots in the toc leaders (0.84em room -> 2 dots)
    \renewcommand\cftchapleader{\leaders\hbox to0.33em{\hss.\hss}\hskip 0.84em plus1fill}
    \renewcommand\cftsecleader{\leaders\hbox to0.33em{\hss.\hss}\hskip 0.84em plus1fill}
    \renewcommand\cftsubsecleader{\leaders\hbox to0.33em{\hss.\hss}\hskip 0.84em plus1fill}
    

    This redefines the leaders to have at least two dots in the line → Longer titles are then hyphenated. For my current TOC this seems so solve the issue completely. I had to play around with the numbers a bit. This combination turned out best

Comments (9)

  1. Ivo Pletikosić

    A few quick ideas:

    1. most typographers will advise you against using very long titles

    2. classicthesis advises against using dottedtoc

    3. if both are really necessary, use the so-called short titles for the TOC \section[Example of a very long title]{Example of a very, very long title that may not fit or if it does is very ugly}

    4. you can also use the short title with a manual line break \section[Example of a very, very long title that may not fit \\ or if it does is very ugly]{Example of a very, very long title that may not fit or if it does is very ugly}

    5. you're also allowed to help hyphenate the problematic word \section{Long section title with a very\-very\-very long\-word}

    Where the lines break is not really up to classicthesis, and I would have to check whether there are any other, automated solutions. Maybe you'll get that answer at https://tex.stackexchange.com/questions/tagged/classicthesis

  2. Fabian Schiemenz reporter

    Hi Ivo. Thanks for answering.

    Your points are generally fair, however it does not really need a long title to ger the behavior once you are at a subsection level.

    For example it happens with the title “Impact of uncertainty realism on space surveillance” → do you consider this to be a long title? I am using the short title for the toc regularly, but sometimes it just cannot be shorter without becoming awkward.

    The interesting thing is that when LateX decides to hypen a word, then it does so correctly, as you can see in the screenshot. But somehow it seems to me as if it considers breaking lines too late.

    The question is also on stackoverflow: https://tex.stackexchange.com/questions/547602/classicthesis-section-title-longer-than-dots

    Looking at the tocloft manual it seems to be as if \@tocrmarg needed some tweaking, but changing the value did nox change or fix anything for me.

    → I would appreciate some further help of you TeX experts. I think this is not a rare issue and also without the dotted line the string would come too close to the number, such that the overall visual apperance could be improved here…

  3. Ivo Pletikosić

    Hi Fabian, All true. You could probably play with line break penalties, or just help LaTeX a bit by telling it (where) to hyphenate - my point #5 above. Surveillance is a long, weird word to hyphenate and the algorithm can't always decide what's best, I guess. I know this also happens elsewhere, and goes unnoticed sometimes even in our "manual". Yet another option would be to change the margin locally, the way we do it in Titlepage.tex. Waiting for someone to answer at stackexchange. Please don't forget to send Andre a postcard.

  4. Fabian Schiemenz reporter

    The hyphen-approach is not really helping I guess. At least \subsection{Impact of uncertainty realism on space sur\-veil\-lance} also does not break → Latex does not seem to consider hyphening necessary in these situations I guess. Let’s see where I can get with line-breaking penalties. The postcard to Andre is due once the work is finished 😉

  5. Fabian Schiemenz reporter

    Hyphen penalties also change nothing, however I got some improvement by using

    %Reduce TOC space after section and subsection number
    \addtolength{\cftsecnumwidth}{-1mm}
    \addtolength{\cftsubsecnumwidth}{-1mm}
    
    %Force a minimum number of dots in the toc leaders (0.84em room -> 2 dots)
    \renewcommand\cftchapleader{\leaders\hbox to0.33em{\hss.\hss}\hskip 0.84em plus1fill}
    \renewcommand\cftsecleader{\leaders\hbox to0.33em{\hss.\hss}\hskip 0.84em plus1fill}
    \renewcommand\cftsubsecleader{\leaders\hbox to0.33em{\hss.\hss}\hskip 0.84em plus1fill}
    

    This redefines the leaders to have at least two dots in the line → Longer titles are then hyphenated. For my current TOC this seems so solve the issue completely. I had to play around with the numbers a bit. This combination turned out best

  6. André Miede repo owner

    Thanks for your answers, I’ll quote Fabian’s reply here so I can pin it to the top:

    Hyphen penalties also change nothing, however I got some improvement by using

    %Reduce TOC space after section and subsection number
    \addtolength{\cftsecnumwidth}{-1mm}
    \addtolength{\cftsubsecnumwidth}{-1mm}
    
    %Force a minimum number of dots in the toc leaders (0.84em room -> 2 dots)
    \renewcommand\cftchapleader{\leaders\hbox to0.33em{\hss.\hss}\hskip 0.84em plus1fill}
    \renewcommand\cftsecleader{\leaders\hbox to0.33em{\hss.\hss}\hskip 0.84em plus1fill}
    \renewcommand\cftsubsecleader{\leaders\hbox to0.33em{\hss.\hss}\hskip 0.84em plus1fill}
    

    This redefines the leaders to have at least two dots in the line → Longer titles are then hyphenated. For my current TOC this seems so solve the issue completely. I had to play around with the numbers a bit. This combination turned out best

  7. Log in to comment