14

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.

  • 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 Jul 22 '12 at 8:37
  • Have a look at tex.stackexchange.com/questions/32234/… – egreg Jul 22 '12 at 22:32
11

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

\documentclass{article}
\makeindex
\makeatletter
\newcommand{\@theindexentry}[1]{%
  \smash{%
    \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
  }%
}
\def\@wrindex#1{%
  \protected@write\@indexfile{}%
    {\string\indexentry{#1}{\thepage}}%
  \endgroup
  \@esphack%
  \@theindexentry{#1}%
}
\def\@index#1{\endgroup\@esphack\@theindexentry{#1}}
\makeatother
\begin{document}
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}.
\end{document}

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! – brannerchinese Jul 24 '12 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 Jul 26 '15 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 May 30 at 14:21
4

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

\newcommand{\@theindexentry}[1]{%
  \smash{%
    \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
  }%
}

\renewcommand\imki@wrindexentrysplit[3]{%
  \expandafter\protected@write\csname#1@idxfile\endcsname{}%
    {\string\indexentry{#2}{#3}}%
    \@theindexentry{#1}%
}

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

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

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.