GeneralLong lines do not wrap around in Table of contents

LaTeX specific issues not fitting into one of the other forums of this category.
niteshs
Posts: 45
Joined: Wed Jun 06, 2012 9:57 pm

Long lines do not wrap around in Table of contents

Post by niteshs »

Hi!
I know this is a very old post, but hopefully this will help others landing here like me. I had the same problem with lines not wrapping in the toc. None of the previous solutions in this post worked for me (the hyperref package was not being used), but after some searching I found a solution that worked for me (thanks to andz at tex.stackexchange) here:

Code: Select all

\addtocontents{toc}{\protect\sloppy}
\tableofcontents
\addtocontents{lot}{\protect\sloppy}
\listoftables
\addtocontents{lof}{\protect\sloppy}
\listoffigures

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Long lines do not wrap around in Table of contents

Post by Stefan Kottwitz »

Thanks for the suggestion! \sloppy is not recommended, however it's easier to use than to adjust parameters yourself. If it makes your table of contents fine, why not. It acts as a switch, so to avoid that the whole text after it is affected, I would switch back to the standard by \fuzzy, after those lists. Btw. using microtype, babel and T1 fonts could already help.

Stefan
LaTeX.org admin
niteshs
Posts: 45
Joined: Wed Jun 06, 2012 9:57 pm

Long lines do not wrap around in Table of contents

Post by niteshs »

Thanks for the additional info Stefan! (perhaps you meant \fussy ?)

Still, in case of toc text wrapping particularly with documents like theses, there tends to be big/long words which seemingly could only be managed by the \sloppy ... \fussy "environment".

Microtype definitely looks like a useful package though. In fact (unless I understood wrong- I only skimmed the introduction :P ), it seems to me that this should be used by default for all typesetting, since it improves things in so many ways.
Any reason why one should not use this package for every single document? I guess it may be unnecessary in most cases, but using it can't hurt?

Edit: I just tried microtype- it not only cleaned up the text elsewhere, it also took care of all the toc wrapping! Again- why is this not invoked by latex as a default for all typesetting ?!
Last edited by niteshs on Thu Jul 19, 2012 11:02 pm, edited 1 time in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Long lines do not wrap around in Table of contents

Post by cgnieder »

niteshs wrote:Microtype definitely looks like a useful package though. [...] Any reason why one should not use this package for every single document? I guess it may be unnecessary in most cases, but using it can't hurt?
Well, it's incompatible with XeTeX and LuaTeX if I remember correctly. I recall that there is a compatible beta version, though. It also can increase compilation time drastically.

Regards
Last edited by cgnieder on Thu Jul 19, 2012 11:08 pm, edited 1 time in total.
site moderator & package author
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Long lines do not wrap around in Table of contents

Post by Stefan Kottwitz »

Yes, I meant \fussy.

I would use microtype for every document, with pdfLaTeX. Even the default optimization, without setting any option, is a good improvement. I don't see a reason not to load it.

Stefan
LaTeX.org admin
niteshs
Posts: 45
Joined: Wed Jun 06, 2012 9:57 pm

Re: Long lines do not wrap around in Table of contents

Post by niteshs »

Hi cgnieder, microtype v2.4 seems to be compatible with luatex ≥ 0.25 (with limited features though). And it seems microtype v2.5 has taken care of the compilation time problem.

Also in case anyone missed my edit: microtype took care of the toc wrapping issue and also cleaned up text elsewhere by quite a bit! Hurray for microtype 8-) !
Post Reply