I have created a name index with the imakeidx package. My question is:

Is it possible to add a label as the key for the index and print e.g. \nameref{label} in the index?

The pseudo-code could look like this:


If the label was a label to a persons name, I would like the name to be printed, and not the label itself. Is that possible and how?

  • You mean a text label then. One problem may arise: \nameref isn't expandable, but as far as I know, \index does not try to expand this at all.
    – user31729
    Commented Dec 15, 2015 at 18:00

1 Answer 1


This is a variation of an older answer by me, writing text labels to the .aux file.

The \labelText command actually be inside the \createPerson command from the other question of the O.P.

I've added an index here to, but only, if the unstarred version is used.


\makeindex[name={nameindex},title={Index of persons}]


 \index[nameindex]{#2}% Do not make an index here


\labelText{Albert Einstein}{label:einstein}


  • Just letting people know, what the other question was :) tex.stackexchange.com/questions/283230/…
    – 7heViking
    Commented Dec 15, 2015 at 21:25
  • 1
    @FireFly3000: I will add the link to the other question to my answer later on
    – user31729
    Commented Dec 16, 2015 at 5:01

You must log in to answer this question.

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