[Tex/LaTex] linebreak fails for long lines in list of figures

line-breaking

When lines becoms long and there are many ~-characters (eg for citing) latex fails to break the line in the list of figures and prints into the margin. any ideas how to "force" a break before the margin?

\documentclass{book}

\begin{document}

\listoffigures

\begin{figure}
\caption{Long  Long  Long  Long Long  Long  Long  Long Long Long Long~Long~Long~Long/Long}
\end{figure}

\begin{figure}
\caption{Long  Long  Long  Long Long  Long  Long  Long Long Long Long~Long~Long~Long}
\end{figure}

\begin{figure}
\caption{Short}
\end{figure}

\end{document}

Best Answer

You can add a bit of glue to allow more stretch:

enter image description here

\documentclass{book}

\begin{document}

\makeatletter
\def\@tocrmarg{2.55em plus 3em}
\listoffigures

\begin{figure}
\caption{Long  Long  Long  Long Long  Long  Long  Long Long Long Long~Long~Long~Long/Long}
\end{figure}

\begin{figure}
\caption{Long  Long  Long  Long Long  Long  Long  Long Long Long Long~Long~Long~Long}
\end{figure}

\begin{figure}
\caption{Short}
\end{figure}

\end{document}