I have a document with numbered paragraphs along the margin, setup as a simple counter. I now want my index using imakeidx to show the relevant number from my counter rather than \thepage, as is done in UK legal textbooks (pictured below). How can I do this?

textbook page showing numbered paragraphs

enter image description here

1 Answer 1


You can patch \@wrindex to use the special counter.

Here I mocked your setup, adjust to your setting.



  \ifnum\value{#1}<10 0\fi
  \ifnum\value{#1}<100 0\fi


%%%% This is the main part!



(a) This is the first section where we deal with apples\index{apple}.

(b) This is the second section where we deal with bananas\index{banana}.


Here we deal with cherries\index{cherry}



enter image description here

  • Lovely! Thank you! Commented Jan 3, 2020 at 22:34

You must log in to answer this question.

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