## Class files

In some big documents, for example books, is customary to make an alphabetic list containing the main terms. With L a T e X and the support program imakeindex , an index can be generated quite easily.

## Introduction

Let's see a simple working example.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{imakeidx}
\makeindex

\begin{document}

\section{Introduction}
In this example several keywords\index{keywords} will be used
which are important and deserve to appear in the Index\index{Index}.

Terms like generate\index{generate} and some\index{others} will
also show up.

\printindex

\end{document}

First, the package is included in the preamble by the line

\usepackage{imakeidx}

Then the command  \makeindex  is mandatory for the index to work and can take some parameters to customize its appearance, in the next sections this will be clear.

To add an entry to the index the command  \index{}  is used, passing as parameter to it the word to be added. Be careful, this won't print the word in the current position but only in the index.

Finally, the command  \printindex  will actually render the index. If you are using a special localization by means of the babel package the title will be translated accordingly.

Note: instead of imakeidx the package makeidx may be imported, but offers less customizations possibilities.

## Entries and subentries

As mentioned in the previous section, the command  \index  will add the word passed to it to the index, but this is not the only way it can be used

\documentclass{article}
\usepackage{imakeidx}
\usepackage[utf8]{inputenc}
\makeindex

\begin{document}

\section{Introduction}
In this example several keywords\index{keywords} will be used
which are important and deserve to appear in the Index\index{Index}.

Terms like generate\index{generate} and some\index{others} will also
show up. Terms in the index can also be nested \index{Index!nested}

\clearpage

\section{Second section}
This second section\index{section} may include some special word,
and expand the ones already used\index{keywords!used}.

\printindex
\end{document}

Is a common practice to extend terms in the index to include special adjectives. For instance, the word Field my have a special meaning if preceded by the adjective finite or followed by of characteristic 0 and it may be a bit cumbersome to add the word Finite several times in the index. For such cases you can add a exclamation mark "!" that will add the therms after this mark as sub entries of the main word.

In the example, the word "Index" has the word "nested" as sub entry.

## Formatting the Index

Simple formatting for the index, such as changing the index title, adding several columns and changing the column width can be easily done passing optional values to  \makeindex 

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{imakeidx}
\makeindex[columns=3, title=Alphabetical Index]

\begin{document}

\section{Introduction}
In this example several keywords\index{keywords} will be used which
are important and deserve to appear in the Index\index{Index}.

Terms like generate\index{generate} and some\index{others} will also
show up. Terms in the index can also be nested \index{Index!nested}

\clearpage

\section{Second section}
This second section\index{section} may include some special word,
and expand the ones already used\index{keywords!used}.

\printindex
\end{document}

In this example the index is presented in a three-column format with the parameter  columns=3  , and the title is changed to "Alphabetical Index" by  title=Alphabetical Index  ; these parameters are passed to  \makeindex  in the preamble. See the reference guide for a list of available parameters and their description.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{imakeidx}
\makeindex[columns=3, title=Alphabetical Index, intoc]

\begin{document}

\tableofcontents

\section{Introduction}
In this example several keywords\index{keywords} will be
used which are important and deserve to appear in the
Index\index{Index}.

Terms like generate\index{generate} and some\index{others}
will also show up. Terms in the index can also be
nested \index{Index!nested}

\clearpage

\section{Second section}
This second section\index{section} may include some special
word, and expand the ones already used\index{keywords!used}.

\printindex
\end{document}

By adding the parameter  intoc  to the command  \makeindex  the inclusion of the index title into the table of contents is enabled.

## Reference guide

Parameters for the  \makeindex  command.

 title 
Title to be typeseted at the beginning of the specific index. An example is presented in formatting the index .
 intoc 
 columns 
 columnsep 
 columnseprule