6

I am trying to do indexing with the following code:

\documentclass[a4paper]{article}
\usepackage{index}
\makeindex
\newindex{aut}{adx}{and}{Name Index}
\begin{document}
Hellow \index[aut]{FiRST}
\printindex[aut]
\end{document}

Acccording to documention of the index package it should work. But makeindex creates empty .idx and .ind.

If I run code like this:

\documentclass[a4paper]{article}
\usepackage{index}
\makeindex
\begin{document}
 Hellow \index{FiRST}
\printindex
\end{document}

It runs. But I need to have user-defined index.

Please help me with it. I've searched for several hours on internet, but without success.

  • 3
    How about using imakeidx? – user11232 Jan 25 '14 at 23:30
9

Since you used \newindex with second argument adx and third argument and, the generated files won't have the default extensions .idx and .ind; the extensions for the associated files in this case will be .adx and .and.

With your settings for \newindex, you need to process your document (I'll assume it's called doc.tex) in the following way: run pdflatex, then makeindex in the special way:

makeindex -o doc.and doc.adx

and pdflatex once more.

For example, in the next example document, three new indices are defined:

\documentclass[a4paper]{article}
\usepackage{index}
\makeindex

\newindex{aut}{adx}{and}{Authors}
\newindex{fru}{fdx}{fnd}{Fruits}
\newindex{mam}{mdx}{mnd}{Mammals}


\begin{document}
\index[aut]{Cervantes}
\index[aut]{Shakespeare}
\index[fru]{Orange}
\index[fru]{Pineapple}
\index[mam]{Horse}
\index[mam]{Whale}


\printindex[aut]
\printindex[fru]
\printindex[mam]
\end{document}

Processing the doucment (again, let's call it doc.tex) using

pdflatex doc
makeindex -o doc.and doc.adx
makeindex -o doc.mnd doc.mdx
makeindex -o doc.fnd doc.fdx
pdflatex doc

gives the three indices:

enter image description here

enter image description here

enter image description here

Some time ago, egreg wrote a nice blog entry regarding building indices. I'm sure you will profit from reading it: (Don't) forget to run MakeIndex. In particular, you can forget the old era of MakeIndex and change to modern times using imakeidx

9

egreg knows that people like me are lazy/ignorant while running extra commands ;-) That is why they wrote imakeidx that makes use of --shell-escape functionality and runs makeindex/xindy automatically. Hence one can (never) forget to run MakeIndex. Here is an example of it (I believe in learning through examples). Compile it with pdflatex (that's all, try it by yourself) and you will get your indices (four of them).

\documentclass[a4paper]{article}
\usepackage{imakeidx}
\makeindex
\makeindex[name=aut,title=Authors,columns=3]  %% Define new index of Authors
\makeindex[name=fru,title=Fruits]  %% Define new index of Fruits
\makeindex[name=mam,title=Mammals]  %% Define new index of Mammals

\begin{document}
Here is some text\index{some thing}.
\index[aut]{Cervantes}
\index[aut]{Shakespeare}
\index[aut]{Shaw}
\index[fru]{Orange}
\index[fru]{Pineapple}
\index[mam]{Horse}
\index[mam]{Whale}

\printindex
\printindex[aut]
\printindex[fru]
\printindex[mam]
\end{document} 

enter image description here

enter image description here

enter image description here

enter image description here

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.