TransWikia.com

How do I force line-breaks in my index?

TeX - LaTeX Asked on March 27, 2021

I have a big book with a lot of index entries. I’m getting some overprinting in the index, like this:

enter image description here

I’ve created a MWE:

documentclass[12pt]{article}
usepackage{makeidx}
makeindex
begin{document}
This is the first page.
index{European Organization for Nuclear Research (CERN)}
index{fable book}
index{fable forger}
index{fable-framing}
index{fable play}
index{fable teller}
index{fabrication tax}
index{fabric spring}
index{fabric tire}
index{face-about}
index{face-ache}
index{face ague}
index{face angle}
index{face-arbor}
index{face bath}
index{face-bedded}
index{face bone}
index{face brick}
index{face card}
index{face-centered}
index{face chuck}
index{face cleat}
index{face cog}
index{face cord}
index{face cover}
index{face cream}
index{faced-lined}
index{face dresser}
index{face dressing}
index{face enamel}
index{face gear}
index{face guard}
index{face hammer}
index{face-harden}
index{face joint}
index{face lathe}
index{face lifting}
index{face mask}
index{face massage}
index{face milling}
index{face mite}
index{face mold}
index{face molder}
index{face-off}
index{face-on}
index{face paint}
index{face painter}
index{face painting}
index{face par}
index{face pit}
index{faceplate coupling}
index{faceplate jaw}
index{face powder}
index{face presentation}
index{face rouge}
index{face-saving}
index{face side}
index{face spanner}
index{face specialist}
index{face sponge}
index{face stone}
index{face string}
index{face towel}
index{face urn}
index{face value}
fontsize{9}{10}selectfont
printindex
end{document}

Without the 12pt, the index looks like this:
enter image description here

With the 12pt, it looks like this:

enter image description here

I’m compiling this with:

$ latexmk  -pdfxe -bibtex idemo.tex ; open idemo.pdf

(I get the same results with -pdf instead of pdfxe)

2 Answers

I'd use imakeidx, which internally uses multicol instead of the standard two-column format. It also doesn't require a separate run of makeindex.

documentclass[12pt]{article}
usepackage{imakeidx}

makeindex
indexsetup{othercode=fontsize{9}{10}selectfont}

begin{document}
This is the first page.
index{European Organization for Nuclear Research (CERN)}
index{fable book}
[...other index entries omitted...]

printindex

end{document}

enter image description here

You can also consider three column format:

documentclass[12pt]{article}
usepackage{imakeidx}

makeindex[columns=3]
indexsetup{othercode=fontsize{9}{10}selectfont}

begin{document}
[...the rest is the same...]

enter image description here

Correct answer by egreg on March 27, 2021

It's not really related to indexing or the document class option, just that some sequences of words are hard to break at some line widths.

Using either

fontsize{9}{10}selectfontraggedright

or

fontsize{9}{10}selectfontsloppy

allows it to break without being over full and sticking in to the next column, the effects are diffeent though you could choose which you prefer.

Answered by David Carlisle on March 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP