11

For reviewing purposes, I'd like to generate a "reverse" index, that would list all the keys per page, instead of the pages per key.

That is, in addition to generating the normal index:

key1.......... 1, 3, 5

key2.......... 2, 4, 5

I'd like:

1: key1

2: key2

3: key1

4: key2

5: key1, key2

Is that possible?

2
  • 1
    are you using the regular \index{...} entry method? if so, it should be possible to do something "sensible" with the .idx file(s) that are generated automatically -- they're already in page number order. i don't know that anyone has done such a thing, but i look into such files all the time to check the input when problems arise. Jun 12 '13 at 17:50
  • 2
    Do you use xindy? Please add a mwe. Jun 12 '13 at 19:43
11

enter image description here

It isn't really a reverse as it is the order the items are collected, it is makeindex that does the reversal to make the normal index.

\documentclass{article}

\usepackage{makeidx} 
\makeindex

\begin{document}

\section{main}
aaa\index{ho} bbb\index{foo}  cc\index{grrr}

\clearpage

aaa\index{ho} bbb\index{foo}  cc\index{grrr}

aaa\index{zho} bbb\index{zfoo}  cc\index{zgrrr}

\clearpage

aaa\index{bho} bbb\index{foo}  cc\index{grrr}



{\clearpage
\section*{xedni}
\makeatletter
\immediate\closeout\@indexfile
\def\lastp{}
\def\indexentry#1#2{%
\def\thisp{#2}%
\ifx\thisp\lastp
\unskip, %
\else
\let\lastp\thisp
\item[#2: ]%
\fi
#1}

\begin{itemize}
\InputIfFileExists{\jobname.idx}{}{}
\end{itemize}
}

\printindex
\end{document}
4
  • Interesting. It doesn't support entries like \index{abc@abd|see{abx}} though.
    – raphink
    Jun 12 '13 at 22:03
  • 4
    well it does something . Define "support" Jun 12 '13 at 22:06
  • Yes, that's hard to support and I guess it does what I described in the question :-)
    – raphink
    Jun 12 '13 at 22:11
  • @ℝaphink you could typest #1 in tt or pseudo-verbatim if you wanted to show the markup, or you could add some macro parsing to dicard the |see bit or do something with @ but it isn't clear in general what is best (and doing nothing is easiest) Jun 12 '13 at 22:19

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.