I am trying to right align the pagenumbers in my index. I use imakeidx and tried to use a custome index style file (.ist). I would like to keep the two column layout of imakeidx. I tried using \hfill as delimiter however this seems to yield always the same width of gap.
How do I rightalign the page numbers while keeping the two column layout?
index.ist-file:
delim_0 "\\hfil"
delim_1 "\\hfil"
delim_2 "\\hfil"
mwe:
\documentclass{report}
\usepackage{imakeidx}
\makeindex[options=-s ./index]
\begin{document}
Indexing\index{what!index} some\index{some} demonstrative\index{demonstrative} entires.
\printindex
\end{document}


\hfilland not\hfil– egreg Sep 09 '13 at 19:40\hfilhas one mile of stretchability, while\hfillhas a trillion miles." If an\hfillexists in the underlying code, it will prevent your\hfils from stretching. That is why you have to fight\hfills with\hfills. – Steven B. Segletes Sep 09 '13 at 19:52\hfillshould do the job. but if there are lots of numbers for an entry, such that more than one line is required, then extra measures will have to be taken. see the texbook, appendix d, pp.392-394 for a rather extreme case (the math. reviews "key index"). it would look even nicer with hanging punctuation, but it was quite enough of a problem in 1980 to get this to work reliably; this was one of the problems i took with me to stanford when i went there to learn tex. – barbara beeton Sep 09 '13 at 20:33