# Avoid line break before page number in the index

This is a bit of a contrived example, as the real one depends on specific fonts I can't post here. MWE:

\documentclass{scrbook}
\usepackage{makeidx}
\usepackage[unbalanced,columns=3,justific=RaggedRight,columnsep=70pt]{idxlayout}
\makeindex
\begin{document}
text\index{this-should-break}
\index{thisss-should-break}
\index{this-one-does-break}
\printindex
\end{document}


Output:

I'd like:

IDX-File:

\indexentry{this-should-break|hyperpage}{1}
\indexentry{thisss-should-break|hyperpage}{1}
\indexentry{this-one-does-break|hyperpage}{1}


IND-File:

\begin{theindex}

\item this-one-does-break, \hyperpage{1}
\item this-should-break, \hyperpage{1}
\item thisss-should-break, \hyperpage{1}

\end{theindex}


I'd like to avoid the line break before the page number for the second entry. I don't know if that's possible at all. I assume I'm looking for a solution that produces something like \item this-should-break,~\hyperpage{1}, but then again, \hyperpage might internally do something to still make it break.

EDIT

As I now not only found a regular but also a xindy solution, I retagged this accordingly.

Seems it's actually pretty easy to achieve, if you know how. The key points are:

• usage of package imakeidx instead of makeidx
• creation of a style file that redefines delim_0

test.ist:

delim_0 ",~"


test.tex:

\documentclass{scrbook}
\usepackage{imakeidx}
\usepackage[unbalanced,columns=3,justific=RaggedRight,columnsep=70pt]{idxlayout}
\makeindex[options=-s test.ist]
\begin{document}
text\index{this-should-break}
\index{thisss-should-break}
\index{this-one-does-break}
\printindex
\end{document}


Resulting ind-File:

\begin{theindex}

\item this-one-does-break,~\hyperpage{1}
\item this-should-break,~\hyperpage{1}
\item thisss-should-break,~\hyperpage{1}

\end{theindex}


Output:

Here's how to do it for xindy:

\documentclass{scrbook}
\usepackage[xindy]{imakeidx}
\usepackage[unbalanced,columns=3,justific=RaggedRight,columnsep=70pt]{idxlayout}
\makeindex[options=-M test.xdy]
\begin{document}
text\index{this-should-break}
\index{thisss-should-break}
\index{this-one-does-break}
\printindex
\end{document}


test.xdy:

(markup-locclass-list :open ",~~")


Output: