# 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}

-
Welcome to TeX.sx! It depends on what you do in your document (class, language, babel or not, two columns index, ...?). Can you please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Kurt Feb 7 at 14:47
Please excuse my noobish question. You're of course right, I'll update my question asap. Thanx. –  Dan Feb 7 at 15:26

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}

-
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.