I can get this by \index{apple|textit}

\item apple, \textit{1}

But i need to have index like this

apple, 3, 4 ex., 12-13 pr.

I tried this, but without any success

  #1 ex.%

EDIT: Minimal example:


  #1 ex.%


Blablabla said Nobody 


Blablabla said Nobody 


Resulted ind-file:


  \item apple, \textit{1}

  • Does it have to use the imakeidxpackage? I know glossaries can do this. Commented Sep 16, 2016 at 17:06

1 Answer 1


If you use xindy you can write in a new file my.xdy these lines:

(define-location-class "arabic-page-numbers"
    ("arabic-numbers") :min-range-length 1)
(define-attributes (("mycommand")))
(markup-locref :open "\mycommand{" :close "}" :attr "mycommand")
(markup-locref-list :open "\myrange{" :close "}" :sep "--" :depth 0 :class "arabic-page-numbers")

and run xindy with -M my option.

See xindy manual and this thread

In the output you can get something like this:

\item apple, \myrange{\textit{1}--\mycommand{2}}
\item banana, \myrange{\mycommand{1}--\mycommand{2}}

And then you redefine the commands and make some kind of switcher:

    #1\ifcase\theprintEX\relax \or{~ex.}\fi%
  • May be you know how to make it works with multipage indices?
    – Yola
    Commented Sep 17, 2016 at 7:44
  • I edited the post a little, added "define-attributes"
    – pantlmn
    Commented Sep 18, 2016 at 10:03
  • Edited once again, added range processing.
    – pantlmn
    Commented Sep 18, 2016 at 10:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .