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. – Guilherme Zanotelli Sep 16 '16 at 17:06

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%
|improve this answer|||||
  • May be you know how to make it works with multipage indices? – Yola Sep 17 '16 at 7:44
  • I edited the post a little, added "define-attributes" – pantlmn Sep 18 '16 at 10:03
  • Edited once again, added range processing. – pantlmn Sep 18 '16 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.