[Tex/LaTex] Use content of keyword field of a bibtex entry to build an index when using biblatex

biblatexbibtexindexing

I built a reading list with biblatex with a – very – long list of court decisions.

The list is built using \nocite{*} once, and then \printbibliography (actually, several \printbibliographys using keyword-based filtering).

In its basic form, stripped of the formatting, the tex file thus looks like this:

\documentclass[%
a4paper,%
12pt,%
twoside%
]%
{book}

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[%
citestyle=biblatex-mcgill,%       
bibstyle=biblatex-mcgill,%
bibencoding=utf8,%
backend=biber,
abstract=true,
sorting=juranote,%
datezeros=false,%
eventdate=short,%
annotation=true,%
rating=true,
hyperref=false,%
]{biblatex}%

\begin{document}

\nocite{*}

\printbibliography[type=jurisdiction]

\end{document}

Biblatex-McGill is my yet to be published Biblatex style, but I think for the sake of this question it is enough to know that it defines "case" as a synonym for the "jurisdiction" entry type.

Each of the 380 entries is extensively tagged with keywords (according to a carefully defined taxonomy of the law). Overall, there must be around 500 different keywords in the bibliography.

In each entry, the keyword field is a comma-seperated list.

My question is: Is it possible to somehow automatically pass the contents of the keyword field at the moment the entry is written to an index and then print an index of all the keywords referring back to all the pages where a decision tagged with the respective keyword/index entry is printed in the bibliography.

Below is a random sample of the kind of entries:

@case{BGH-2012-07-12-IX-ZB-267-11,
Crossref = {BGH},
Date = {2012-07-12},
Date-Added = {2012-11-14 13:27:04 +0200},
Date-Modified = {2012-11-14 12:23:37 +0000},
Eventdate = {2012-07-12},
Keywords = {Einwendungen gegen den Titel (internationales Vollstreckungsrecht), Vollstreckungs- und Anerkennungsrecht (internationales), BGH, IZVR, JB-gesehen, Zivilrecht},
Note = {Beschl.},
Number = {IX ZB 267/11},
Rating = {5}}

@case{BVerfG-2009-10-15-2-BvR-2438-08,
    Additionalreporter = {NJW 2010, 287, wistra 2010, 60},
    Crossref = {BVerfG},
    Date = {2009-10-15},
    Date-Added = {2012-11-11 14:32:00 +0200},
    Date-Modified = {2012-11-13 19:26:58 +0000},
    Keywords = {JB-gesehen, außerhalb von Wohnungen nichtöffentlich gesprochenes Wort, Kaiser, Examen, Strafprozessrecht, BVerfG, Strafrecht, Ermittlungsmaßnahmen},
    Note = {Beschl.},
    Number = {2 BvR 2438/08},
    Preferredreporter = {BVerfGK 16, 299},
    Rating = {5}}

@case{VGHMannheim-2008-04-30-5-S-2858-06,
    Crossref = {VGHMannheim},
    Date = {2008-04-30},
    Date-Added = {2012-11-02 12:00:00 +0000},
    Date-Modified = {2012-11-13 19:24:44 +0000},
    Eventdate = {2008-04-30},
    Keywords = {Straßen- und Wegerecht, Verwaltungsrecht, Verjährung (unvordenkliche), Verwaltungsrecht AT, VGH Mannheim, Examen, JB-gesehen},
    Note = {Urt.},
    Number = {5 S 2858/06},
    Preferredreporter = {BWGZ 2008, 950},
    Rating = {5}}

@case{OLGStuttgart-2011-11-22-10-W-47-11,
    Crossref = {OLGStuttgart},
    Date = {2011-11-22},
    Date-Added = {2012-11-12 13:10:40 +0200},
    Date-Modified = {2012-11-13 16:12:12 +0000},
    Eventdate = {2011-11-22},
    Keywords = {einstweilige Verfügung (ZPO), Sachenrecht, OLG Stuttgart, petitorische Einwendungen (gegen den Besitzschutzanspruch), Examen, Besitz (als absolutes Recht), Zivilverfahrensrecht, Störerhaftung, einstweiliger Rechtsschutz (ZPO), Zivilrecht, Besitzstörung, Kaiser, absolute Rechte, JB-gesehen, Besitz},
    Note = {Beschl.},
    Number = {10 W 47/11},
    Rating = {3}}

@case{BGH-2008-11-28-LwZR-9-08,
    Crossref = {BGH},
    Date = {2008-11-28},
    Date-Added = {2012-11-13 17:14:27 +0200},
    Date-Modified = {2012-11-13 16:10:58 +0000},
    Eventdate = {2008-11-28},
    Keywords = {Sachenrecht, Zivilrecht, Examen, BGH, Besitz, Herausgabeanspruch des früheren Besitzers},
    Note = {Urt.},
    Number = {LwZR 9/08},
    Rating = {3}}

@case{BGH-2012-10-25-VII-ZB-31-12,
    Crossref = {BGH},
    Date = {2012-10-25},
    Date-Added = {2012-11-13 16:50:35 +0200},
    Date-Modified = {2012-11-13 15:47:33 +0000},
    Eventdate = {2012-10-25},
    Keywords = {Zwangsvollstreckungsrecht, Vollstreckungsverfahren, Fahrnispfändung, Geldforderung (Vollstreckung wegen), Examen, Zivilverfahrensrecht, Forderungspfändung, Zivilrecht, BGH, Unpfändbarkeit, JB-gesehen},
    Note = {Beschl.},
    Number = {VII ZB 31/12},
    Rating = {4}}

Best Answer

Here is a solution using the imakeidx package (it should work with other approaches to indexes as well):

\usepackage{imakeidx}
\makeindex[name=keywords, title=List of Keywords]

BibLaTeX has commands for producing index entries: first of all we have to define the format for the index. keywords in BibLaTeX is a field with comma separated values, thus we can use \forcsvfield to parse single keywords, and to pass them to the handler which consists of a call \index[keywords].

\DeclareIndexFieldFormat{keywords}{\forcsvfield{\index[keywords]}{keywords}}

Then we have to ensure that the keywords are inserted in the keyword index: a possibility is to add the call to \indexfield{keywords} every time a bibitem is processed.

\AtEveryBibitem{\indexfield{keywords}}

If the custom style has an instruction to print the keywords (e.g., \usebibmacro{keywords}) then \indexfield{keywords} could be inserted in the macro.

Finally:

\printindex[keywords]
Related Question