I will be working with a professional indexer of the old school — meaning that she prefers making her index on cards using a pencil while looking at a finished book whose pagination will not change — and am searching for tools that will lessen the stress involved for both of us. Neither index cards nor static pagination are a viable option in the present case.

Are there any tools that would enable me to show exactly what words have been indexed in a given line in some unobtrusive way — say by underlining or shading them in the text?

I am aware of the \showidx package, which is useful. Its weakness in my situation is that it takes the whole page as its domain of operation, which it not easy for the indexer to follow; I'm looking for something that actually marks the indexed text, or at least makes \showidx-like margin notations on the same line as the indexed text.

  • 1
    I usually mark important and thus indexed terms with \emph. I'd suggest also putting a little symbol into the margin. So you could end up with \newcommand[1]{\index{#1}\emph{#1}\marginpar{\small IDX}}.
    – bodo
    Commented Jul 22, 2012 at 8:37
  • Have a look at tex.stackexchange.com/questions/32234/…
    – egreg
    Commented Jul 22, 2012 at 22:32

2 Answers 2


I'm just throwing this idea out there; not sure whether it might be of help. It is somewhat inspired by David's showkeys package:

enter image description here

    \rlap{\rule{.4pt}{.8\baselineskip}}% Vertical rule
    \begin{lrbox}{\@tempboxa}\tiny\ttfamily#1\end{lrbox}% Box index entry
    \rlap{\raisebox{.6\baselineskip}{\usebox{\@tempboxa}}}% key
Lorem\index{Alpha} ipsum dolor sit amet, consectetur\index{alpha} adipiscing elit. 
Proin ullamcorper\index{gnat} quam magna, quis convallis\index{gnus!good} sapien. Donec 
at ligula vel dolor varius\index{bites!vegetable} lobortis id ut orci\index{gnat!size of}. Maecenas 
commodo fringilla elit\index{Alphabet}, et pellentesque purus ornare vitae. 
Aenean non metus ipsum. Lorem\index{gnat!anatomy} ipsum dolor sit amet, consectetur 
adipiscing\index{alphas} elit. Ut mauris lorem, accumsan a sagittis ut, 
rutrum fringilla arcu. Cras ullamcorper faucibus\index{alpha bet} quam id molestie.

Nunc et\index{alphabet} sem et turpis semper adipiscing et id nibh. In nibh 
mauris, placerat sed consequat placerat, dignissim ut\index{at!bat|see {bat, at}} arcu. 
Aenean eleifend justo volutpat lectus\index{gnus!bad} interdum pellentesque. 
Etiam cursus varius\index{twenty@xx} tellus, non pretium nibh tempus sit amet. 
Suspendisse sed mauris nisl. Cum sociis natoque penatibus et 
magnis dis parturient montes, nascetur\index{alpha@$\alpha$} ridiculus mus. Nullam 
at feugiat nisi\index{bites!animal!gnats}.

It prints, for every \index, a vertical rule showing the point of reference, as well as the key used (minus { or }, for simplicity) in \tiny\ttfamily. Using xcolor one could make the appearance less intrusive by printing in black!30 (say):

enter image description here

\@theindexentry prints the index-related content. \smash takes care of any vertical adjustment, while the entire index entry is set inside a zero-width \rlap to remove any horizontal adjustment.

The definition of \@wrindex (in the presence of \makeindex) and \@index was taken directly from latex.ltx.

  • More than exactly what I had in mind! Commented Jul 24, 2012 at 0:39
  • Small problem with this solution is that it adds extra vertical space, if \index occurs right after headings and some environments. e.g. quote. To avoid this it helps to put \hspace{0pt} right before \smash.
    – Florian
    Commented Jul 26, 2015 at 10:38
  • This method does not work with documentclass memoir: from the first invocation of index{ in the body of the document, it gives error Extra \endgroup with details \@index #1->endgroup, a line feed, and \@esphack \@theindexentry {@1}. Is there a fix that will allow it to work with memoir, too?
    – murray
    Commented May 30, 2019 at 14:21

I know this is an old post, but for future reference, I had success with the following using imakeidx.

    \rlap{\rule{.4pt}{.8\baselineskip}}% Vertical rule
    \begin{lrbox}{\@tempboxa}\tiny\ttfamily#1\end{lrbox}% Box index entry
    \rlap{\raisebox{.6\baselineskip}{\usebox{\@tempboxa}}}% key


The @theindexentry is taken directly from Werner's post.

  • 1
    If you are using more than one index, change the last line accordingly, e.g. to \@theindexentry{#1: #2}%
    – Florian
    Commented Jul 10, 2015 at 22:05

You must log in to answer this question.

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