3

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}
9
  • 1
    makeindex, imakeidx, xindy ... Say you want the index, mark the items to be indexed and print the index at the appropriate point in the document. Compile, run makeindex or xindy or neither as required. Compile.
    – cfr
    Commented Apr 14, 2016 at 22:57
  • @cfr I wanna use the package imakeidx. Is necessary, when I make \index{key} that the key belongs to the text? I wanna put the abstract in the index, but the word abstract doesn't belong to the text. Is that possible? Commented Apr 14, 2016 at 23:01
  • 1
    It makes no sense to put the title of the abstract into the index. My advice would therefore be not to do it regardless.
    – cfr
    Commented Apr 14, 2016 at 23:05
  • 1
    It would be rather easier to help you if you provided a minimal example document. If you want working code with an index as an example, provide working code without an index for people to start from. The index will stay in the second page if you ask for it to printed at a point in the source which turns out to be on the second page and if the index is no longer than one page. Like anything else except floats, it will print where you put it.
    – cfr
    Commented Apr 14, 2016 at 23:12
  • 1
    Did you run xindy as Bernard said and then recompile?
    – cfr
    Commented Apr 15, 2016 at 0:22

1 Answer 1

6

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

11
  • 1
    Please see my completed answer. Hope I've been clear enough.
    – Bernard
    Commented Apr 14, 2016 at 23:53
  • 1
    Could you post a fully compilable code?
    – Bernard
    Commented Apr 15, 2016 at 0:14
  • 1
    I think this answer would be far more useful to a complete (index) novice if it were actually an MWE. A truly exemplary answer would also include the steps involved in getting to the final product (with the file extensions so the novice could understand what file is for what purpose).
    – jon
    Commented Apr 15, 2016 at 1:47
  • 1
    @CarmenGonzález: I modified my answer. You don't have any index because it seems imakeidx takes into account only the \index commands written before \printindex, for some reason. There's a workaround using the older makeidx package and makeindex (the program).
    – Bernard
    Commented Apr 15, 2016 at 13:00
  • 1
    @jon: I modified my answer to take into account your pertinent remark. Doing so I found out a problem with imakeidx: \printindex has to be used after all items have be indexed.
    – Bernard
    Commented Apr 15, 2016 at 13:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .