GeneralIndex Creation

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
chaneyfrank
Posts: 2
Joined: Tue Jun 21, 2011 4:40 pm

Index Creation

Post by chaneyfrank »

Help,
Im new to latex, and have successfully created my first project, which is a book. I want to finish the book by creating an index at the end of the document. I have succeeded, but have encountered a small problem,
When the index is compiled, the text or word selected for the index is placed in the index and prints successfully, but removes the selected text or word from the document. I use MiKTeX version 2.8 and quite like it. The code I use is as follows.

Code: Select all

\documentclass[12pt, openany, a4paper,]{book}
\usepackage[dvips]{graphicx}
\usepackage{makeidx}

\makeindex

\begin{document}
\tableofcontents 
\input{filename.tex}
\printindex
\end{document}
Can anyone help to solve this problem?
Last edited by localghost on Wed Jun 22, 2011 12:55 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

paul
Posts: 49
Joined: Thu Apr 08, 2010 5:56 am

Re: Index Creation

Post by paul »

What do you mean "removes the selected text or word from the document"? Are you doing "blah blah \index{foo} blah blah" and expecting "blah blah foo blah blah" to appear in your book? Doesn't work like that. You need to say "blah blah foo\index{foo} blah blah", with "foo" appearing twice (or write a macro to do the same).
VijayKParmar
Posts: 3
Joined: Fri Oct 14, 2011 3:21 pm

Re: Index Creation

Post by VijayKParmar »

Hi I tried creating an Index in the amsbook documentclass with the code listed above. I don't get an Index just more complilation errors.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Index Creation

Post by cgnieder »

You you please provide a Infominimal working example that recreates the error? The following works nicely:

Code: Select all

\documentclass[12pt, openany, a4paper,]{book}
\usepackage[dvips]{graphicx}
\usepackage{makeidx}

\makeindex

% I don't know your filename.tex so I provide my own:
\usepackage{filecontents}
\begin{filecontents*}{filename.tex}
\chapter{Blah}
\section{Blah Blah}
\index{Sample entry}
\end{filecontents*}

\begin{document}
\tableofcontents
\input{filename.tex}
\printindex
\end{document}
Regards
site moderator & package author
VijayKParmar
Posts: 3
Joined: Fri Oct 14, 2011 3:21 pm

Re: Index Creation

Post by VijayKParmar »

Thanks cgnieder. I tried your code on TeXCenter -no luck. In fact it creates a file which uses up all of the CPU!! I have to delete it.
First thing to notice is in \documentclass{amsbook}
\usepackage{makeidx} doesn't work
There is a clash
in
\documentclass{book}

no clash but still no index! In the older templates which cam with TeXCenter the index was automatic!
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Index Creation

Post by cgnieder »

Well, the errors produced with amsbook say
! LaTeX Error: Command \see already defined.
and
! LaTeX Error: Command \printindex already defined.
which suggests that amsbook provides its own indexing commands. So just leave makeidx out:

Code: Select all

\documentclass{amsbook}
\makeindex

% I don't know your filename.tex so I provide my own:
\usepackage{filecontents}
\begin{filecontents*}{filename.tex}
\chapter{Blah}
\section{Blah Blah}
\index{Sample entry}
\end{filecontents*}

\begin{document}
\tableofcontents
\input{filename.tex}
\printindex
\end{document}
Regards
site moderator & package author
Post Reply