Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
3  
How about using imakeidx? –  Harish Kumar Jan 25 at 23:30
add comment

2 Answers

up vote 8 down vote accepted

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

share|improve this answer
    
Thank you, very helpful! With best regards, Sergey. –  saldenisov Jan 26 at 15:04
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.