| 1 |
% |
| 2 |
% This file demonstrates indexing with the 'index' package. |
| 3 |
% This file is processed as follows: |
| 4 |
% |
| 5 |
% latex file |
| 6 |
% bibtex/biber file |
| 7 |
% latex file |
| 8 |
% makeindex -o file.ind file.idx (= makeindex file) |
| 9 |
% makeindex -o file.nnd file.ndx |
| 10 |
% makeindex -o file.tnd file.tdx |
| 11 |
% latex file |
| 12 |
% |
| 13 |
% Note that the file name suffix may be omitted. It's 'latex file' |
| 14 |
% and not 'latex file.tex'. Also note that '-t <file>' is optional. |
| 15 |
% |
| 16 |
\documentclass[a4paper]{article} |
| 17 |
\usepackage[T1]{fontenc} |
| 18 |
\usepackage[utf8]{inputenc} |
| 19 |
% |
| 20 |
% The 'index' package provides advanced indexing facilities with |
| 21 |
% support for multiple indexes. |
| 22 |
\usepackage{index} |
| 23 |
\usepackage[american]{babel} |
| 24 |
\usepackage{csquotes} |
| 25 |
% |
| 26 |
% We set the 'indexing' package option and use the 'authortitle' |
| 27 |
% style in this example. |
| 28 |
\usepackage[indexing,style=authortitle,autolang=hyphen,backend=biber]{biblatex} |
| 29 |
\addbibresource{biblatex-examples.bib} |
| 30 |
% |
| 31 |
% We want three indexes: a general index, an index of names, and an |
| 32 |
% index of titles. They are defined by way of \newindex, see the |
| 33 |
% documentation of the 'index' package for details. |
| 34 |
\newindex{default}{idx}{ind}{Subject Index} |
| 35 |
\newindex{names}{ndx}{nnd}{Name Index} |
| 36 |
\newindex{titles}{tdx}{tnd}{Title Index} |
| 37 |
% |
| 38 |
% We need to redefine some index formatting directives such that |
| 39 |
% biblatex adds names and titles to separate indexes. All names |
| 40 |
% should go to the name index, hence we simply redefine the default |
| 41 |
% index formatting directive for names. The default definition, |
| 42 |
% which is found in biblatex.def, looks like this: |
| 43 |
% |
| 44 |
% \DeclareIndexNameFormat{default}{% |
| 45 |
% \usebibmacro{index:name}{\index}{#1}{#3}{#5}{#7}% |
| 46 |
% } |
| 47 |
% |
| 48 |
% As you can see, the data is simply passed on to a 'bibmacro' which |
| 49 |
% takes care of the formatting of the name. The definition of the |
| 50 |
% bibmacro, which is also found in biblatex.def, is not relevant in |
| 51 |
% our example because all we want to do is change or rather extend |
| 52 |
% the \index command, which happens to be the first argument of the |
| 53 |
% 'index:name' bibmacro. |
| 54 |
% |
| 55 |
\makeatletter |
| 56 |
\@ifpackageloaded{biblatex_legacy} |
| 57 |
{\DeclareIndexNameFormat{default}{% |
| 58 |
\usebibmacro{index:name}{\index[names]}{#1}{#3}{#5}{#7}}} |
| 59 |
{\DeclareIndexNameFormat{default}{% |
| 60 |
\usebibmacro{index:name}{\index[names]} |
| 61 |
{\namepartfamily} |
| 62 |
{\namepartgiven} |
| 63 |
{\namepartprefix} |
| 64 |
{\namepartsuffix}}} |
| 65 |
\makeatother |
| 66 |
% |
| 67 |
% Titles are handled in a similar way. The formatting directive we |
| 68 |
% need to modify is 'indextitle'. It's default definition looks like |
| 69 |
% this: |
| 70 |
% |
| 71 |
% \DeclareIndexFieldFormat{indextitle}{% |
| 72 |
% \usebibmacro{index:title}{\index}{#1}% |
| 73 |
% } |
| 74 |
% |
| 75 |
% We modify it such that the \index command writes to the index of |
| 76 |
% titles: |
| 77 |
% |
| 78 |
\DeclareIndexFieldFormat{indextitle}{% |
| 79 |
\usebibmacro{index:title}{\index[titles]}{#1}% |
| 80 |
} |
| 81 |
% |
| 82 |
% That's it as far as splitting the index is concerned. Let's have a |
| 83 |
% look at some other facilities you may want to customize. By |
| 84 |
% default, biblatex will index the author or editor and the title of |
| 85 |
% all references. This behavior may be modified as desired. The |
| 86 |
% indexing facilities are not hard-coded. All standard styles which |
| 87 |
% ship with this package call two 'bibmacros' which handle the |
| 88 |
% indexing. These macros are called 'citeindex' and 'bibindex', both |
| 89 |
% of which are defined in biblatex.def. The former handles indexing |
| 90 |
% in citations, the latter in the bibliography. Their default |
| 91 |
% definitions are as follows: |
| 92 |
% |
| 93 |
% \newbibmacro*{citeindex}{% |
| 94 |
% \ifciteindex |
| 95 |
% {\indexnames{labelname}% |
| 96 |
% \indexfield{indextitle}} |
| 97 |
% {}} |
| 98 |
% |
| 99 |
% \newbibmacro*{bibindex}{% |
| 100 |
% \ifbibindex |
| 101 |
% {\indexnames{labelname}% |
| 102 |
% \indexfield{indextitle}} |
| 103 |
% {}} |
| 104 |
% |
| 105 |
% The 'labelname' field is a copy of the 'author' field, if there is |
| 106 |
% an author, or a copy of the 'editor' field otherwise. 'indextitle' |
| 107 |
% is the 'indextitle' field, if defined in the bib file, or a copy |
| 108 |
% of the 'title' field otherwise. |
| 109 |
% |
| 110 |
% The mechanism works like this: the \indexnames and \indexfield |
| 111 |
% fields tell biblatex which data to add to the index, the indexing |
| 112 |
% directives tell it how to index the data. |
| 113 |
% |
| 114 |
% The default settings should be fine in most cases. As an example, |
| 115 |
% we will modify them here such that author, editors, translators, |
| 116 |
% and commentators in the bibliography are indexed: |
| 117 |
% |
| 118 |
\renewbibmacro*{bibindex}{% |
| 119 |
\ifbibindex |
| 120 |
{\indexnames{author}% |
| 121 |
\indexnames{editor}% |
| 122 |
\indexnames{translator}% |
| 123 |
\indexnames{commentator}% |
| 124 |
\indexfield{indextitle}} |
| 125 |
{}} |
| 126 |
% |
| 127 |
\begin{document} |
| 128 |
|
| 129 |
\section*{Indexing with the \texttt{index} package} |
| 130 |
|
| 131 |
% We add the contents of the entire bib file to the bibliography. |
| 132 |
% Note that \nocite does not add anything to the index on its own. |
| 133 |
\nocite{*} |
| 134 |
|
| 135 |
% We cite a few items. These citations will be added to the index. |
| 136 |
\cite{piccato,gaonkar,malinowski,coleridge,gerhardt,cicero} |
| 137 |
|
| 138 |
% We also add an explicit index entry. |
| 139 |
\index{Example entry} |
| 140 |
|
| 141 |
\clearpage |
| 142 |
|
| 143 |
% We print the printbibliography... |
| 144 |
\printbibliography |
| 145 |
% ...and the indexes |
| 146 |
\raggedright |
| 147 |
\printindex % the general index |
| 148 |
\printindex[names] % the name index |
| 149 |
\printindex[titles] % the title index |
| 150 |
|
| 151 |
\end{document} |