# Index moves the text to index

Here is the file I am working with.

\documentclass[12pt,a4paper]{book}
\usepackage{xkeyval}
\usepackage{polyglossia}
\usepackage{xcolor}
\usepackage{makeidx}
\usepackage{multicol}

\setmainfont[Script=Devanagari]{Sanskrit 2003}
\makeindex
\begin{document}
\printindex

\chapter*{प्रथमाध्यायः}

\index{धर्मक्षेत्रे कुरुक्षेत्रे} समवेता युयुत्सव: । \\
मामका: पाण्डावश्चैव किमकुर्वत सञ्जय ॥ १ ॥
\end{document}


In the above example I want the first two words of the verse to appear in index, it does appear in the index but its deleted from the verse. Am I doing something wrong.

-
Please stick to one question per post here: there seem to be three different issues here. – Joseph Wright Oct 11 '11 at 16:29
should I post two other questions and refer to this post, – Aku Oct 11 '11 at 16:29
If there is a conceptual link to this one, then a reference is fine. However, I did not really see the link beyond 'indexing'. There was nothing in the two other parts to the question that seemed to rely on the first issue here. – Joseph Wright Oct 11 '11 at 16:32

## 2 Answers

You're not doing anything wrong, that's the default behaviour.

A solution is to use the index package instead of makeidx and use the starred \index macro provided by that package. This prints the word(s) in both text and index.

\documentclass[12pt,a4paper]{book}
\usepackage{xkeyval}
\usepackage{polyglossia}
\usepackage{xcolor}
\usepackage{index}
\usepackage{multicol}

\setmainfont[Script=Devanagari]{Sanskrit 2003}
\makeindex
\begin{document}
\printindex

\chapter*{प्रथमाध्यायः}

\index*{धर्मक्षेत्रे कुरुक्षेत्रे}
धर्मक्षेत्रे कुरुक्षेत्रे समवेता युयुत्सव: । \\
मामका: पाण्डावश्चैव किमकुर्वत सञ्जय ॥ १ ॥
\end{document}

-
@Joseph - it worked, thanks for your help. – Aku Oct 11 '11 at 16:40

The argument to \index is independent of the text of your document. Thus if you want to index an item which is also in the text, you either need to repeat it

\documentclass[12pt,a4paper]{book}
\usepackage{xkeyval}
\usepackage{polyglossia}
\usepackage{xcolor}
\usepackage{makeidx}
\usepackage{multicol}

\setmainfont[Script=Devanagari]{Sanskrit 2003}
\makeindex
\begin{document}
\printindex

\chapter*{प्रथमाध्यायः}

\index{धर्मक्षेत्रे कुरुक्षेत्रे}%
धर्मक्षेत्रे कुरुक्षेत्रे समवेता युयुत्सव: । \\
मामका: पाण्डावश्चैव किमकुर्वत सञ्जय ॥ १ ॥
\end{document}


or define a custom command to do this 'behind the scenes':

\documentclass[12pt,a4paper]{book}
\usepackage{xkeyval}
\usepackage{polyglossia}
\usepackage{xcolor}
\usepackage{makeidx}
\usepackage{multicol}

\setmainfont[Script=Devanagari]{Sanskrit 2003}
\makeindex
\newcommand\alsoindex[1]{\index{#1}#1}
\begin{document}
\printindex

\chapter*{प्रथमाध्यायः}

\alsoindex{धर्मक्षेत्रे कुरुक्षेत्रे}
धर्मक्षेत्रे कुरुक्षेत्रे समवेता युयुत्सव: । \\
मामका: पाण्डावश्चैव किमकुर्वत सञ्जय ॥ १ ॥
\end{document}


The \index command is a bit odd as it does various verbatim-like tricks, but for simple text the approach of a wrapper should work.

-
u mean i have to create index and copy/paste the text that I want to appear in the index page. Is there any other way to do where I can avoid the copy/paste part – Aku Oct 11 '11 at 16:36