[Tex/LaTex] Make a Index for a report

indexing

I have to put a index on my report because the report is too long. How I create and what packages I have to use to make a index for a report? I need a index appropriate to a report. I wanna the index in the second page of my report. (after the cover)

\documentclass{article}  
\usepackage{imakeidx} 
\makeindex[program=xindy, options=-C utf8 -L portuguese]
\begin{document} 
\printindex 
\begin{abstract} Estudou-se o valor da acelera\c{c}\~{a}o grav\'{i}tica
\end{abstract} 
\section{Objectivos do Trabalho} 
A finalidade da experi\^{e}ncia\index{finalidade da experi\^{e}ncia} de: 
\end{document}

Best Answer

I suggest making it with xindy, which has the advantage to understand utf8 if you have accented letters. Loading the imakeidx package, you obtain the index in one compilation.

You need two commands: \makeindex[options to pass to the index compiler] in the preamble, and printindex at the place where you want it in your document. However, unless I've missed something, there seems to be one restriction: \printindex has to be used only after all items are indexed. The index{…} commands which appear afterwards won't be written in the .idx file.

Here is a code:

\documentclass[portuguese]{article}
\usepackage[utf8]{inputenc} \usepackage[T1]{fontenc}
\usepackage{babel}%
 \usepackage{imakeidx}%
\makeindex[program=xindy, options=-C utf8 -L portuguese]%

\begin{document}

\begin{abstract} Estudou-se o valor da aceleração gravítica\index{valor}
\end{abstract}
\section{Objectivos do Trabalho}
A finalidade da experiência \index{finalidade da experiência} de:

\printindex

\end{document} 

enter image description here

If you really need your index at the beginning of your document, you can load the makeidx package, insert the \makeindex command in the preamble and \printindex in the document body. Then compile with pdflatex + makeindex + pdflatex. As accented letters are not understood by makeindex, you have to index items with \index{sortingtext@text-with-accents}. Here is an example:

\documentclass[portuguese]{article}
\usepackage[utf8]{inputenc} \usepackage[T1]{fontenc}
\usepackage{babel}%
 \usepackage{makeidx}%
\makeindex

\begin{document}

\printindex
\begin{abstract} Estudou-se o valor da aceleração gravítica\index{valor}
\end{abstract}
\section{Objectivos do Trabalho}
A finalidade da experiência \index{finalidade@finalidade da experiência} de:

\end{document} 

enter image description here

Related Question