Showing first {{hits.length}} results of {{hits_total}} for {{searchQueryText}}{{hits.length}} results for {{searchQueryText}}
In some big documents, for example books, is customary to make an alphabetic list containing the main terms. With LaTeX and the support program imakeidx, an index can be generated quite easily. Contents 1 Introduction 2 Indices on Overleaf 3 Entries and subentries 4 Formatting the Index 4.1 Using style files 5 Including the index in the table of contents 6 Reference guide 6.1 Parameters for the \makeindex command 6.2 Keys to create styles files 7 Further reading  Introduction Let's see a simple working example. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \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, where the word to be added is inserted as the parameter. 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.   Open an example of the imakeidx package in Overleaf  Indices on Overleaf When adding an index to a project on Overleaf, it is important to note that for the index to compile properly, the main .tex file needs to be in the root directory of the project, outside of any folders. This ensures that the auxiliary files needed to generate the index are cached in a way that they are accessible to the compiler.  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} \usepackage[T1]{fontenc} \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 may 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 terms after this mark as sub entries of the main word. In the example, the word "Index" has the word "nested" as sub entry.   Open an example of the imakeidx package in Overleaf  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[T1]{fontenc} \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.  Using style files For further customization of the index one can use a style file. Style files inform makeindex about the intended format of the final output. Style files contain a list of pairs. For instance, if one needs to group the terms in the index by their initial letter and align the page numbers to the right, the next style file will do the job: headings_flag 1   heading_prefix "\n\\centering\\large\\sffamily\\bfseries% \\noindent\\textbf{"heading_suffix "}\\par\\nopagebreak\n"   item_0 "\n \\item \\small "   delim_0 " \\hfill " delim_1 " \\hfill " delim_2 " \\hfill " They keys change different elements in the index output: headings_flag = 1 enables grouping inserting the group header (symbols, numbers or letters) before a new group. heading_prefix formats the header to insert before a new letter begins. It uses regular formatting commands for the font family, font eight and alignment, but the backslashes must be escaped using a double backslash instead of one. item_0 is what will be inserted between two primary items. delim_* is the delimiter to be inserted between the key and the first page number. For a full list of keys and values to use in a .ist file see The table included in the reference guide. Assume the previous file is saved as "example_style.ist". To use it in the document we add the parameter options= -s example_style.ist to the \makeindex command. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{imakeidx} \makeindex[columns=3, title=Alphabetical Index, options= -s example_style.ist]   \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}, a great\index{great} list and som other\index{others} terms that might be important\index{important} 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}   Open an example of the imakeidx package in Overleaf  Including the index in the table of contents By default, the index is not included in the table of contents, this can be easily reverted. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \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.   Open an example of the imakeidx package in Overleaf  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 If this option is passed the index title is put in the table of contents. columns Uses the syntax key=value, the value must be an integer representing the number of columns. The default value is 2. columnsep Units that represent the separation between the columns. The syntax must be key=value, for example columnsep=2em. columnseprule If this is set, a vertical ruler will be rendered between the columns.  Keys to create styles files The next table shows the keys, default values and descriptions to create .ist stile files. key Description actual '@' Symbol indicating that the next entry is to appear in the output file. arg_close '}' Closing delimiter for the index entry argument. arg_open '{' Opening delimiter for the index entry argument. encap ' Symbol indicating that the rest of the argument list is to be used as the encapsulating command for the page number. escape '\\' Symbol which escapes the following letter, unless its preceding letter is escape. Note: quote is used to escape the letter which immediately follows it, but if it is preceded by escape, it is treated as a ordi- nary character. These two symbols must be distinct. keyword "\\indexentry" Command which tells makeindex that its argument is an index entry. level '!' Delimiter denoting a new level of subitem. quote '"' Note: quote is used to escape the letter which immediately follows it, but if it is preceded by escape, it is treated as a ordinary character. These two symbols must be distinct. range_close ')' Closing delimiter indicating the end of an explicit page range. range_open '(' Opening delimiter indicating the beginning of an explicit page range. preamble "\\begin{theindex}\n" Preamble of output file. postamble "\n\n\\end{theindex}\n" Postamble of output file. setpage_prefix "\n \\setcounter{page}{" Prefix of command which sets the starting page number. setpage_suffix "}\n" Suffix of command which sets the starting page number. group_skip "\n\n \\indexspace\n" Vertical space to be inserted before a new group begins. headings_flag 0 Flag indicating treatment of new group headers, which are inserted when before a new group (symbols, numbers, and the 26 letters): posi- tive values cause an uppercase letter to be inserted between pre- fix and suffix, and negative values cause a lowercase letter to be inserted (default is 0, which pro- duces no header). heading_prefix "" Header prefix to be inserted before a new letter begins. symhead_positive "Symbols" Heading for symbols to be inserted if headings_flag is positive. symhead_negative "symbols" Heading for symbols to be inserted if headings_flag is negative. numhead_positive "Numbers" Heading for numbers to be inserted if headings_flag is positive. numhead_negative "numbers" Heading for numbers to be inserted if headings_flag is negative. item_0 "\n \\item " Command to be inserted between two primary (level 0) items. item_1 "\n \\subitem " Command to be inserted between two secondary (level 1) items. item_2 "\n \\subsubitem " Command to be inserted between two level 2 items. item_01 "\n \\subitem " Command to be inserted between a level 0 item and a level 1 item. item_x1 "\n \\subitem " Command to be inserted between a level 0 item and a level 1 item, where the level 0 item does not have associated page numbers. item_12 "\n \\subsubitem " Command to be inserted between a level 1 item and a level 2 item. item_x2 "\n \\subsubitem " Command to be inserted between a level 1 item and a level 2 item, where the level 1 item does not have associated page numbers. delim_0 ", " Delimiter to be inserted between a level 0 key and its first page number (default: comma followed by a blank). delim_1 ", " Delimiter to be inserted between a level 1 key and its first page number (default: comma followed by a blank). delim_2 ", " Delimiter to be inserted between a level 2 key and its first page number (default: comma followed by a blank). delim_n ", " Delimiter to be inserted between two page numbers for the same key in any level (default: comma fol- lowed by a blank). delim_r "--" Delimiter to be inserted between the starting and ending page numbers of a range. delim_t "" Delimiter to be inserted at the end of a page list. This delimiter has no effect on entries which have no associated page list. encap_prefix "\\" First part of prefix for the command which encapsulates the page number. encap_infix "{" Second part of prefix for the com- mand which encapsulates the page number. encap_suffix "}". Suffix for the command which encap- sulates the page number. line_max 72 Maximum length of a line in the output, beyond which a line wraps. indent_space "\t\t" Space to be inserted in front of a wrapped line (default: two tabs). indent_length 16 Length of indent_space (default: 16, equivalent to 2 tabs).   Open an example of the imakeidx package in Overleaf  Further reading For more information see: Glossaries Lists of tables and figures Table of contents Sections and chapters Hyperlinks International language support Cross referencing sections and equations Management in a large project Multi-file LaTeX projects imakeidx package documentation