Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have two questions:

  1. Is it possible to change the titel of the printindex command? It is "Index" by default.
  2. How can I format the index as a multi column, alphabetic sorted list?

printindex title Alphabetically sorted printindex

share|improve this question

5 Answers 5

up vote 13 down vote accepted

the answers depend on what document class you're using. however,

  1. both the basic latex classes (book et al.) and and ams-latex classes (amsbook et al.) provide the command \indexname with a default value "Index". so

    \renewcommand{\indexname}{New name}
    

    will change the title. (the babel package does this already for a number of languages.)

  2. both book.cls and amsbook.cls provide a two-column index style. if you're creating your own class, you might consider "borrowing" the code from one of those classes. documented code is given in the .dtx files classes for basic latex and amsclass for the ams-latex classes. "human readable" versions of the documented code are given in .pdf files of the same names as the .dtx files. all are on ctan, and they are probably also on your tex installation; try typing texdoc classes or texdoc amsclass at the command line.

to get the content sorted, you need to use makeindex; that is well documented in several places, including lamport's latex manual and the "companionn", as well as with texdoc makeindex. be sure to pay attention to the use of the "sort field" for math entries, entries with accented letters, and other special cases that may cause entries to diverge from the expected alphabetical order.

share|improve this answer
  1. Redefine \indexname. For example:

    \renewcommand\indexname{The Index}
    
  2. There are imakeidx and idxlayout packages to change the style of the index. Columns and headings, and other settings.

  3. You can specify a .ist file when using makeindex program to change the output of makeindex. See the document of makeindex.


A sample .ist file:

% sample.ist
% Usage
%     makeindex -s sample.ist foo.aux
preamble "
\\begin{theindex}
  \\providecommand*\\indexgroup[1]{\\indexspace
    \\item \\textbf{#1}\\nopagebreak}
"

postamble "\n\n\\end{theindex}\n"

group_skip "  %\n  \\indexspace\n  %\n"

headings_flag 1
heading_prefix "  %\n  \\indexgroup{"
heading_suffix "}\n  %\n"

numhead_positive "Numbers";
numhead_negative "Numbers";
symhead_positive "Symbols";
symhead_negative "Symbols";
share|improve this answer

I'm just expanding Leo Liu's item #2 a little. imakeidx can easily help you on setting a custom index title and column numbers through (from documentation):

  • title: is the title that is typeset at the beginning of the specific index; if not specified, the \indexname value is used.

  • columns: accepts an integer representing the number of columns in the index; this is silently ignored if the original or the twocolumn options are set; the number can even be 1.

A quick addition to your document preamble:

\usepackage{imakeidx}
\makeindex[title=My custom index title,columns=2]

will do the job. If you have, say, a custom mystyle.ist style, you can also use the options option as well:

  • options: is the list of options to be passed to the sorting and formatting program; this list is a balanced text of program options, separated with the syntax required by the sorting and formatting program. For example, in order to use a different makeindex sorting and formatting style mystyle.ist and avoiding any message in the screen output write options=-s mystyle.

Regarding a custom makeidx style, unfortunately I have no experience with it. I strongly recommend chapter 11 from "The LaTeX Companion" book, called Index Generation. :)

share|improve this answer
  1. Redefine \indexname like this : \renewcommand{\indexname}{My index}.

  2. You define a .ist file that stores your preferences for the style of the index. For the example you want (alphabetic list starting by the letters and dots before page numbers), you add the following lines to your .ist file :

>     heading_prefix "{\\bfseries\\hfil "
>     heading_suffix "\\hfil}\\nopagebreak\n" 
>     headings_flag 1

and also

delim_0 "\\dotfill"
delim_1 "\\dotfill"
delim_2 "\\dotfill"

If it based on a book derived class, the index will be on two columns anyway.

share|improve this answer

I am using amsmidx. I had to use

\backmatter
\addcontentsline{toc}{chapter}{Author Index}
\renewcommand{\indexname}{Author Index}
\printindex{author}
\addcontentsline{toc}{chapter}{Subject Index}
\renewcommand{\indexname}{Subject Index}
\printindex{subject}

Don't add the index name to \printindex or you will get two indexes with each name, use \renewcommand{\indexname}{My Index Name} instead. Thanks to two commenters below, but adding a \clearpage just before the second \addcontentsline made my table of contents disappear.

share|improve this answer
    
With what package for multiple indices? –  egreg Jan 1 '12 at 21:35
    
The \clearpage after \backmatter is superfluous because \backmatter will issue \clearpage resp. \cleardoublepage (depending on the state of @openright). On the other hand, a \clearpage before the second \addcontentsline is missing, and this will cause a wrong page number entry in the ToC. –  lockstep Jan 1 '12 at 21:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.