The OP asked also asked about hyperref
. I can make it work in a test case, thanks to this answer, but I worry very much potential side effects. Use it in a production document at your own risk!
\documentclass{article}
\begin{filecontents}{\jobname.mst}
delim_0 "\\space"
delim_1 "\\space"
delim_2 "\\space"
delim_n "\\idxBdelim"
\end{filecontents}
\usepackage{imakeidx}
\usepackage{hyperref}
\makeindex
\makeatletter
\def\idxBdelim{\@ifnextchar{\hyperindexformat}{;\space}{,\space}}
\def\@commahyperpage#1{\@@commahyperpage#1\idxBdelim{}\idxBdelim{}\\}
\def\@@commahyperpage#1\idxBdelim#2\idxBdelim#3\\{%
\ifx\\#2\\%
\HyInd@pagelink{#1}%
\else
\HyInd@pagelink{#1}\idxBdelim\HyInd@pagelink{#2}%
\fi
}
\makeatother
\begin{document}
Some words. A test.
\index{words}
\index{phrases|see{words}}
\newpage
Words and sentences.\index{words}\index{sentences}
\newpage
Sentences.\index{sentences}
\index{sentences|seealso{words}}
\printindex
\end{document}
Possible side-effects:
- This essentially blows up how
\hyperpage
works with comma-separated list of elements.
- I cannot detect
\seealso
; I only detect the wrapper that \hyperref
puts around \seealso
; but the same wrapper also gets placed around \see
, so use it at your own peril.
A potentially better solution would be to try to fully expand what (say) 1\idxBdelim2
would expand to before passing it into \hyperpage
; this would not require modifying the underlying mechanics of \hyperpage
. Unfortunately I couldn't make it work.