1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
%
% This file demonstrates indexing with the 'imakeidx' package.
% This file is processed as follows:
%
% latex file
% bibtex/biber file
% latex file
% latex file
%
% Note that the file name suffix may be omitted. It's 'latex file' and not
% 'latex file.tex'. Also note that '-t <file>' is optional.
%
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
%
% The 'imakeidx' package provides advanced indexing facilities with support for
% multiple indexes. Unlike the 'index' package, 'imakeidx' does not generate
% "self-protecting" index entries. So we need to protect control sequences in
% indexing fields from expansion. For an example see the 'knuth:ct:a' entry in
% biblatex-examples.bib.
%
\usepackage{imakeidx}
\usepackage[american]{babel}
\usepackage{csquotes}
%
% We set the 'indexing' package option and use the 'authortitle'
% style in this example.
%
\usepackage[indexing=cite,style=authortitle,autolang=hyphen,backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}
%
% We want two indexes: an index of names with title subentries, an index of
% titles organized by year. They are defined by way of \makeindex, see the
% documentation of the 'imakeidx' package for details.
%
\makeindex[name=name-title,title={Name and Title Index}]
\makeindex[name=year-title,title={Year and Title Index}]
%
% A 'name:title' indexing bibmacro can be found in biblatex.def. It takes the same
% arguments as the 'index:name' bibmacro. Note that the title fields are accessed
% inside the name indexing directive. So we have to test for missing titles.
%
\DeclareIndexNameFormat{name:title}{%
\iffieldundef{title}
{\usebibmacro{index:name}{\index[name-title]}{#1}{#3}{#5}{#7}}
{\usebibmacro{index:name:title}{\index[name-title]}{#1}{#3}{#5}{#7}}}
%
% Auxiliary indexing macros in biblatex.def can be used to define additional
% indexing directives with subentries. The following directive creates entries
% for the year-title index.
%
\DeclareIndexFieldFormat{with:year}{%
\iffieldundef{year}
{\usebibmacro{index:entry}{\index[year-title]}{%
\mkbibindexentry{0}{Not dated}%
\subentryoperator%
\mkbibindexfield{\thefield{indexsorttitle}}{\emph{#1}}}}
{\usebibmacro{index:entry}{\index[year-title]}{%
\thefield{year}\subentryoperator%
\mkbibindexfield{\thefield{indexsorttitle}}{\emph{#1}}}}}
%
% We redefine the 'citeindex' bibmacro to use the new indexing directives.
%
\renewbibmacro*{citeindex}{%
\ifciteindex
{\indexnames[name:title]{labelname}%
\indexfield[with:year]{indextitle}}
{}}
\begin{document}
\section*{Indexing with the \texttt{imakeidx} package}
% We cite a few items. These citations will be added to the indexes.
\cite{knuth:ct,knuth:ct:a,knuth:ct:c,knuth:ct:d}
\cite{aristotle:anima,aristotle:poetics,aristotle:physics,aristotle:rhetoric}
\clearpage
% We print the printbibliography...
\printbibliography
% ...and the indexes
\raggedright
\printindex[name-title] % the name-title index
\printindex[year-title] % the year-title index
\end{document}
|