# How to avoid bad boxes in the index?

I'm currently writing a larger document, which will also contain an index. Unfortunetely, the index produces a lot of bad boxes. Plase find a small example at the bottom.

My simple (but hopefully not too stupid) question is whether there is a way to avoid this. Rephrasing the index entries is not really an option as there are several long words.

Another possibility would be to just 'filter out' warning messages that appear in the index. Is there a way to do this?

\documentclass[paper=A4, fontsize=11pt, draft]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage[onehalfspacing]{setspace}
\usepackage{makeidx}
\usepackage[fleqn]{amsmath}
\usepackage{amsthm,amssymb}
\usepackage{tikz}
\usepackage{xspace}
\usepackage{booktabs}

\clubpenalty=9999
\widowpenalty=9999
\displaywidowpenalty=9999

\makeindex

\begin{document}

\emph{automata learning}\index{Automata learning|see{Algorithmic learning}}

\printindex

\end{document}

-

Loading the microtype package should reduce the number of ("underfull hbox") warnings. Another (or an additional) option is to set the index \RaggedRight (still allowing hyphenation) using my idxlayout package (which internally uses ragged2e).

\documentclass{article}

\usepackage{microtype}

\usepackage{makeidx}
\makeindex

\usepackage[justific=RaggedRight]{idxlayout}

\usepackage{lipsum}

\begin{document}

Some text.\index{\lipsum*[1]}

\printindex

\end{document}​


EDIT: In your added example, the actual problem is an "overfull hbox" not prevented by microtype. Using \RaggedRight is still an option; as an alternative, you may set \emergencystretch to a positive value (say, 1em) for the index.

\documentclass[draft]{scrbook}

\usepackage{microtype}

\usepackage{makeidx}
\makeindex

\begin{document}

\emph{automata learning}\index{Automata learning|see{Algorithmic learning}}

\begingroup
\emergencystretch=1em

\printindex

\endgroup

\end{document}

-

in my opinion, book indexes should almost always be set ragged right; indexes with justified material are "justifiable" only under very special conditions (see the texbook, pp.392-394 in appendix d for one such situation -- and even here, ragged right alternates with ragged left to avoid really bad spacing that would result from full justification).

scrbook.cls shows no evidence of using a ragged setting, so my advice would be to add it. i would probably do it by redefining theindex; see the definition of \theindex in amsbook.cls for an idea on where best to incorporate it.

whether you use the original \raggedright or the modified version from ragged2e doesn't really make a lot of difference in this situation.

-