The authorindex Package

Andreas Wettstein

                wettstae@ise.ch

September 2002

Abstract

The authorindex package lists all authors cited in a L^{A}TEX 2ε document from the \cite entries and their associated .bib bibliography files. It will not run with bibliographical entries (\bibitem) explicitly typed into the document. Each author entry in the generated list contains the pages where these citations occur. Alternatively, the package can list the labels of the citations that appear in the references rather than the text pages. The package requires perl (version 5 or higher) to run an auxiliary script and BibTEX. The package can be used by itself or as a preprocessor for makeindex. It can produce separate indices and mini indices, which are merged in the bibliography. The package can run under Unix, Windows, or MS-DOS. The authorindex package is compatible with the standard bibliographical styles distributed with L^{A}TEX 2ε and with hyperref. With the small patches listed here, it will also run with the chapterbib, chicago, harvard, and natbib bibliographical style packages.

1 Installation

The authorindex package consists of the L^{A}TEX style file authorindex.sty and the perl script authorindex. It needs L^{A}TEX 2ε, BibTEX [1] and perl (version 5 or better) to run.

To install the package, move authorindex.sty to a place where L^{A}TEX looks for its style files. Unix: The perl script authorindex must be moved to a place in your executable path and be given execution permission. You may need to modify the path to the perl binary that appears in the first line of the script authorindex, replacing /usr/bin/perl by the correct path for your system. MS-DOS: A perl processor for MS-DOS such as ActivePerl can process the L^{A}TEX auxiliary file .aux in a command window to produce the authorindex file .ain.

2 Using the package

The L^{A}TEX source code includes the authorindex package via a \usepackage statement. It may also be necessary to replace your \cite commands by \aicite commands^{1}. The \aicite command behaves like \cite but writes additional information to the .aux file needed to generate the author index.

1If you put the statement \let\cite=\aicite in the preamble after the loading of the package, \cite commands will be equivalent to \aicite commands, and you will not need to modify your text.

Additional commands are available. The command \aimention enters a name into the author index that does not appear in the bibliography file .bib. It is not strictly a “citation” command because it doesn’t add a citation to the text. Its argument is an author name in the BibTEX name format like \aimention{Carl Friedrich Gau{\ss}}, for example. This command is designed to bridge the gap with keyword indices and might be useful for referring to famous people whose work (in contrast to their publications) is common knowledge. Multiple names are possible if they are separated by and as in the standard BibTEX author format. The command \aionly expects a bibliography key and puts the corresponding authors in the author index without generating a citation. In a sense, it is similar to \nocite.

Producing the author index requires only a few steps. Run the perl script authorindex and L^{A}TEX sequentially; the procedure is similar to producing the bibliography output from BibTEX. The command \printauthorindex marks the point where the author index is to appear in the L^{A}TEX output. A typical sequence to run the tools would be L^{A}TEX, BibTEX, authorindex, L^{A}TEX, authorindex, L^{A}TEX. For MS-DOS or Windows, the authorindex step would be processed in a command window by an explicit statement like perl authorindex example [cr], where example is the name of the .aux file and “[cr]” indicates the enter key. In a Unix environment, the authorindex script can be invoked

simply by the statement authorindex example [cr].

Options to the authorindex package are available, invoked in the usually way

\usepackage[option...]{authorindex}. The option withbib automatically

indexes the page where a bibliography entry appears in the references. There is also the possibility of generating an index that is merged into the corresponding bibliography entries themselves. This possibility is switched on by the package option miniindex discussed more below.

The details of including the author index are left to the author. Unlike the L^{A}TEX commands \printindex or the \thebibliography, the command \printauthorindex does not create a chapter or section heading. To format the author index in multiple columns on a page in a one-column document, use an additional package like multicol. With this package, a two-column author index will be created with

\begin{multicols}{2}
\printauthorindex
\end{multicols}

If you plan to generate several documents with author indices in a consistent style, consider redefining the theauthorindex environment to fit your needs.

3 Overall structure of the index

3.1 Normal .ain file

The .ain file created by the perl script authorindex from the .aux file and used by \printauthorindex will look like this:

\begin{theauthorindex}
\item[May, Karl] \aipages{\aifirstpage{iv}, 2, \aibibpage{77}}
\item[Musil, Robert] \aipages{7, 9, \aibibpage{\aifirstpage{77}}}

\indexspace
\item[Schmidt, Arno] \aipages{33, \aibibpage{78}}
\item[Souter, Nathaniel] \aipages{29--\aifirstpage{36}}
\end{theauthorindex}

Note the provision for both text and bibliographical pages. Author names that start with different letters are separated by the statement \indexspace, which inserts a blank line between the groups. This command has no arguments but can be redefined according to your needs inside or outside the theauthorindex environment. Also, note the provision for a sequential range of pages.

3.2 Font sizes

The command \aisize controls the font size used for the author index. It expects no arguments. You can redefine it outside the theauthorindex environment to customize the font size. In most cases, it will be sufficient to use one of those options in the authorindex package:

small will cause the author index to be typeset in small size.

normal (the default) will cause the author index to be typeset in the normal text size.

3.3 Separate entries for first and other authors

By default, authorindex generates exactly one entry for each author in the index. All pages with citations of the author’s work go into this entry, no matter what the co-authors for the work that you cite are.

You can change this behavior with the \aisee command. You call \aisee in the preamble of your document with a string argument. For authors that are not the first in the author list of a work cited, authorindex generates an entry with this authors name, followed by the string you have given to \aisee, followed by the name of the first author of the cited work. Entries for authors that are first (or even only) authors of a work are listed in the author index as usual.

For example, if you write in German, you’d put

\aisee{, siehe }

in your preamble. If you write in English, you would use “see” instead of “siehe”. For example, assume that we cite works with the following author lists: “A. Schmidt, R. Musil, and K. May” (cited on page 4); “R. Walser and K. May” (and page 4 and 5); “R. Musil” (on page 3); ‘R. Musil and N. Souter” (on page 5); “N. Souter and R. Musil” (on page 2 and 6). Then, the entries starting with “M” in the .ain file look like like

\item[\aitop{May, K.}, siehe \aifirst{Schmidt, A.}] \aipages{4}
\item[\airep{May, K.}, siehe \aifirst{Walser, R.}] \aipages{4, 5}
\item[Musil, R.] \aipages{\aifirstpage{3}, \aifirstpage{5}}
\item[\airep{Musil, R.}, siehe \aifirst{Souter, N.}] \aipages{2, 6}
\item[\airep{Musil, R.}, siehe \aifirst{Schmidt, A.}] \aipages{4}

3.4 Mini indices

Alternatively (or additionally) to the usual author index, you can use the package option miniindex in the preamble to cause authorindex to merge a mini index directly into your bibliography file; that is, the merge modifies the .bblfile. This procedure requires that you run authorindex after you run bibtex. The page list is put into the single argument of the command \bibindex. By default, \bibindex prints nothing if its argument is empty. Otherwise, it passes the argument to \aibibindex, which prints the pages in bold type enclosed by braces (for example, {10, 11, 36}), as in Nelson F. Beebe’s author index package [2]. For alternatives, you can redefine \aibibindex using \renewcommand. For obvious reasons, a mini index always contains the page numbers, even if the biblabels package option is used.

Normally, the mini index is placed at the end of each item. You can change this by hacking your bibliography style file. Let it place \bibindex{} on it’s own line where you want the mini index to go, and authorindex will do the rest.

4 Author names

4.1 Which names to include in the index?

There are two package options to authorindex to select which type of names to include in the index:

editors will cause the editor names to be included in the author index.

avoideditors will cause the editors names to be included only if there are no author names present for a cited work

onlyauthors (the default) will restrict the author index to the author names.

Previous comments concerning authors will also apply to editors when the editors option is invoked.

The command \aimaxauthors[trunc]{max} limits the maximum number of authors per work that will be included in the author index. The optional first argument trunc determines the number of authors to be included if the maximum number is exceeded. If it is omitted, trunc is assumed equal to max. Thus, \aimaxauthors[1]{3} will set the maximum number of authors to 3; for works with more than three authors only the first one will be included. In this example, for a work by “A. Schmidt, R. Musil, and K. May”, all of them will appear in the author index while, for a four-author work by “A. Schmidt, R. Musil, K. May, and N. Souter”, only Schmidt will. This usage is similar to the “et al.” commonly used in in bibliographies. With \aimaxauthors{3}, on the other hand, for works with more than 3 authors, the 3 first ones will be included. For the two example author lists, in both cases, Schmidt, Musil, and May will be listed.

The authorindex package accepts package options for only the most important cases:

onlyfirst sets the maximum number of authors (or editors) per work that will be included in the index to 1. It corresponds to \aimaxauthors{1}. all (the default) sets the maximum number of authors (or editors) per work

that will be included to 9999. It corresponds to \aimaxauthors{9999}.

4.2 Formatting and sorting

The command \ainamefmt contains the specification for formatting and ordering names. Its argument is a string consisting of one or more parts separated by semicolons. Each part is made up of one or two components, separated by a colon. If there is only one component, the both components are assumed to be equal. Each of the two component consists of a BibTEX-format string [3]. The first component formats the way the names are printed in the index; the second component, the way the names are sorted. It is therefore possible to include the same name multiple times in the index, each time sorted or printed differently. One restriction is that you cannot have different printed representations that have the same sort format. Because \ainamefmt can be messy to use, a few simple cases can be selected by options to the authorindex package:

lastname will only include the last name of the authors (and titles like “von”, if

present). firstabbrev will also include the abbreviated first name(s) (and eventually also a

“jr.”), following the last name. fullname (the default) will spell the names in full, to the extent given in the .bib

file.

For example, the package options fullname, lastname, and firstabbrev correspond following uses of \ainamefmt:

\ainamefmt{{vv }{ll}{, ff}{, jj}}} % fullname
\ainamefmt{{vv }{ll}}}             % lastname
\ainamefmt{{vv }{ll}{, f.}{, jj}}} % firstabbrev

For a more complex example, assume we want to format the names like for firstabbrev but, in addition to the normal sorting, we also want to sort in names that have a ‘von’-part ignoring that part. In other words, we want C. F. von Weizsäcker to appear both under “V” and “W” in the index, but nonetheless always typeset as “von Weizsäcker, C. F.”:

\ainamefmt{%
  {vv }{ll}{, f.}{, jj};%
  {vv }{ll}{, f.}{, jj}:{ll}{vv }{, f.}{, jj}%
}

This approach would also work for name prefixes like “van” or “de la”.

Note that the command \indexspace, which separates entries that start with a different letters, is placed according to the format used for sorting.

4.3 Fonts for the names

\ainame is a command with one argument. It determines how the argument of \item inside the theauthorindex environment is printed.

The command \aifirst has one argument. It is used to typeset the name of the leading author from an entry with an additional author when using the command \aisee. The command \aitop typesets the name of the first occurrence of an additional author, that is, an author name before the string defined

by \aisee.

Finally, \airep typesets a name that has already been used in the previous index entry. Look at the example in section 3.3 for clarification.

By redefining these commands, you can do more than just selecting fonts. One example would be to redefine

\renewcommand{\airep}[1]{---}

to cause the name of an author to printed only once when it occurs in many subsequent entries.

4.4 Advanced customization

If the standard command \ainamefmt does not provide enough flexibility, you can use the command \authorindexstyle in the preamble. Its single argument is the name of some .bst-file that you select to format the author names.

If you decide to write a custom .bst-file, it is necessary to understand hacking .bst files, e. g. by reading [3]. Your BibTEX style file needs to generate a .bbl file that contains three lines for each author-label pair. The first line is the name formatted according to your taste, as it appears in the index. The second line is the name format used for sorting. The third line contains the label of the citation, or is empty. In the latter case, the label of the previous three line entry is taken; furthermore, this entry is assumed to refer to the same author as the current one — differing only in the formatting or sorting rule. The default .bst file used to format the names is embedded in the perl script authorindex. You could use this as template. Use the command line option -k for authorindex (see Sec. 6).

The first author of the work is expected to be dumped into the .bbl file first.

5 Page numbers and bibliography labels

5.1 Page numbers or bibliography labels?

You have to possibility of selecting whether you want the page numbers or the bibliography numbers of the references to appear in the index. This selection is done through the package options

biblabels will include in the author index the reference label as it appears in the reference list instead of the page numbers.

pages (the default) the pages of the citations.

With the option biblabels, every citation will be indexed. There is no need to use the special citation commands \aicite, unless you want to have a mini index as well (see section 3.4). With this option, it makes no sense to use either the \aimention command or the withbib package option.

While this manual has referred to “pages, ” it also applies to the indexing of bibliography labels unless explicitly noted otherwise.

5.2 Ordering of pages and compression of page ranges

The command \aipagetypeorder{order} can be used to determine the relative order of different types of page numbers, such as roman, arabic, and others. The argument order is a string consisting of a selection of the characters rRnAa, which indicate lowercase roman, uppercase roman, arabic, uppercase alphabetic, and lowercase alphabetic page numbers, respectively. The relative order of the letters in the string determine the order of the page numbers. For example, the argument rn will sort all lowercase roman pages before the arabic pages. If you want to use lowercase alphabetic numbers, you have to use \aipagetypeorder without putting r in the string; that is, you can’t use lowercase roman numbers and lowercase alphabetic numbers at the same time. The same holds for using uppercase roman and alphabetical page numbers. Composite page numbers (like “4-17”) are split into their components (using any character that cannot be interpreted as a digit as field separator) and sorted with the priority of components decreasing from left to right.

Normally, three or more adjacent page numbers are “compressed.” If an author citation appears on pages 4.17, 4.18, and 4.19, the page range will appear as “4.17–4.19” in the index entry. However, a range of only two consecutive pages will not be compressed. To represent such a pair by the first page number plus some string (typically, “f”), specify that string as the argument of \aitwosuffix in the preamble. You can suppress range compression altogether by using the nocompress package option.

5.3 Fonts used for the pages

The command \aipages determines the overall font of the page numbers. The \aibibpage command is used to switch on additional properties to mark the pages that contain the bibliography entries of works of the author — relevant if the withbib package option is used. \aifirstpage is used to print page numbers of references in which the author is the leading author. All three commands expect one argument and can be redefined by \renewcommand.

5.4 Modifying the page numbers

The command \theaipage determines the string representing the page delivered to the perl script authorindex. This does not apply to bibliography labels, even if the biblabels package option is used. By default, this is simply defined as \thepage, but you can redefine it. Originally, allowing \theaipage to differ from \thepage was intended for multi-volume books, where the page numbers in each volume do not indicate the volume number. For example, page 231 of volume II will produce only a plain “231” as the page number, whereas you might prefer to have the indication of the volume in the index such as “II-231”. You can also do more sophisticated things. For example, using the hyperref package with the plainpages=false option to create hyperlinks to the page where the citation is:

\def\theaipage{\string\hyperpage{\thepage}}

NB: To avoid keep authorindex from interpreting the string \hyperpage as an alphabetic page number, you should not use alphabetic page numbering and tell the perl script about it using \aipagetypeorder.

6 Running authorindex

Having run L^{A}TEX on the properly prepared L^{A}TEX source document, you then use the perl script authorindex to process the generated .aux-files, which produces the author index file (extension .ain).

The perl script can be called with any number of arguments. Without arguments, authorindex reads from the standard input. With several arguments, authorindex appends .aux extensions wherever necessary and processes these files. The output is written to the file whose name is extracted from the .auxfile where \printauthorindex was given. It is necessary to give the .aux-file produced by the .tex-file containing \begin{document} to authorindex; this file passes information to the script regarding the style and content of the index.

If you use \include in your L^{A}TEX source document, it is sufficient to give the master .aux-file to authorindex; the .aux-files of included files are then processed automatically.

authorindex recognizes the following command line options:

-d (“draft”) Adds additional information to the .ain file: For each author, the labels of all references and the page numbers where they are cited are included as comments. This detail may help if you manually edit the generated author index. Also, some statistics are included at the bottom of the .ain file. This option does not work with the -i option.

-h (“help”) Prints out a short help text.

-i (“index”) Creates a file suitable for further processing with makeindex or the like. For example, you could use that to make a common author and subject index. Note the extension of the generated file still will be .ain. (Use the -p option and redirection to send the stuff anywhere else.)

-k (“keep”) Retains the temporarily generated .bst-file after authorindex finishes. This information will give you a good starting point for advanced customization of the author index (see Sec. 4.4).

-p (“print”) Prints the result to standard output instead of writing it to the .ain-file.

-r (“do not recurse”) Does not automatically process .aux-files produced by included files.

7 authorindex and other packages

7.1 Compatible packages

7.1.1 Standard distribution package

The standard cite package included with the L^{A}TEX distribution seems to work with authorindex without problems.

7.1.2 chapterbib

The chapterbib package also works well with authorindex. If you want to use the mini indices, be sure to run authorindex separately on the main .aux-file plus the .aux-file for each chapter using the -r option (see section 6). In addition, you may want to run authorindex on the main .aux-file to generate an author index for all chapters. For example, you might use a sequence of the form:

 authorindex -r main chapter1
 authorindex -r main chapter2
 authorindex main

If you require chapterwise author indices, after the first two authorindex runs in the above example, you should rename main.ain to something else and \input these files in the place where you want the chapterwise authorindex to appear.

7.1.3 hyperref

The script authorindex works well with hyperref. In the standard version, the pages in the author index are not linked back to the page with the citation. Section 5.4 describes how to fix this problem.

7.2 Less compatible packages

Most problems with other bibliographical packages arise because the packages override or skip certain citation functions. The authorindex package modifies these functions to write page information along with the citation key to the .aux file. In the following examples, we show how to re-establish this additional output for a few specific packages. Please note that these “fixes” may no longer work if newer versions of these packages appear.

7.2.1 chicago

The standard version of the chicago package does not work with authorindex. For this package, there is a patch that apparently makes it work with authorindex. In the file chicago.sty, you replace the lines

\def\@citex[#1]#2{%

with

\def\@citex[#1]#2{\@aicitey{#2}%

and

\def\@citedatax[#1]#2{%

with

\def\@citedatax[#1]#2{\@aicitey{#2}%

and save the modified file under a new name, e. g. aichicago.sty. Use this file in place of the file chicago.sty.

7.2.2 harvard

The harvard package can be made to work with authorindexby adding code to the document preamble. After loading the harvard package with \usepackage, write the following lines into the preamble of your L^{A}TEX-source file:

\makeatletter
\renewcommand{\HAR@citetoaux}[1]{%
  \if@filesw\immediate\write\@auxout{\string\citation{#1}}\fi%
  \if@filesw\@for\@citeb:=#1\do{\immediate\write\@auxout{%
      \string\citationpage{\@citeb}{\thepage}}}\fi}%
\makeatother

Then, in the main text, use the harvard citation commands \cite, \citeyear, etc., exactly as you would normally do without the authorindex package.

7.2.3 natbib

Like chicago, the package natbib also conflicts with authorindex. Michael Friendly and Patrick W. Daly devised a fix for Nelson Beebe’s authidx package [2], which the former posted to comp.text.tex. With a few changes, it seems to work for authorindex too. You insert in your natbib.cfg the following lines:

% natbib.cfg
% Asoundingly Egregious Hack to make natbib work with authorindex
% package:
% - This tacks on to \NAT@citex, which is just for author-year
%   style citations.  There's probably a better way
\AtBeginDocument{%
\@ifpackageloaded{authorindex}{%
  \let\org@@citex\NAT@citex
  \def\@citex[#1][#2]#3{%
    \typeout {indexing: [#1][#2]{#3}}
    \org@@citex[#1][#2]{#3}\@aicitey{#3}}}{}}
\endinput

Please note that I tested this work-around superficially. It does not repair a conflict that occurs when the authorindex package option withbib is used.

8 Problems and restrictions

Currently, I am aware of the following problems and restrictions:

• Compression of page numbers ignores whether the pages will be printed in the same font; that is, you might get something like “7–9”.

• Compression always uses the full page numbers, that is you will always get something like “4.8–4.10” rather than “4.8–10”.

• Sorting of names is restricted. At this time, special characters are stripped, the case is ignored, and a normal comparison according to the ASCII Code is done. This might not be what you want if you have accented characters. Consider using the option -i in conjunction with additional processing by a more flexible tool.

• If you use \aicite with multiple arguments and a page break occurs within the list of generated references, one part of the citations will be associated with the wrong page.

• The package will fail for author names longer than 79 characters (including spaces, commas, etc) or for very long citation labels. These force a line break in BibTEX output. Future versions of BibTEX may help.

• You can not use the package when you explicitly type your bibliography in your L^{A}TEX file (\bibitem) instead of using BibTEX. Consider using BibTEX instead. It is a powerful bibliographical tool worth the small additional effort.

9 Acknowledgement

I want to thank Mark A. Gordon for his substantial improvements to the language and presentation in this manual.

References

[1] O. Patashnik. BibTEXing (1988). Documentation for general BibTEX users.

[2] N. H. F. Beebe. AUTHIDX: An author/editor indexing package. TUGboat 19(1):1001–1007 (1998).

[3] O. Patashnik. Designing BibTEX styles (1988). The part of BibTEX’s documentation that’s not meant for general users.