Automatische Indizierung von Referenzen nach Autor und Jahr

Automatische Indizierung von Referenzen nach Autor und Jahr

Ich schreibe eine Literaturübersicht und möchte Indizes für Autoren und Veröffentlichungsjahr hinzufügen (also zweiseparateIndizes). Nun könnte ich die entsprechenden \index{}Befehle manuell eingeben, aber es scheint, als könnte dies von Biblatex automatisch erledigt werden. Es würde die Wartung sicherlich viel einfacher machen, ein wichtiger Aspekt, da ich beabsichtige, die Rezension in den nächsten Jahren auf dem neuesten Stand zu halten, während ich mit meiner Forschung fortschreite.

Ich habe mit der Indexierungsoption gespielt, die in biblatex eingebaut ist, aber ich weiß nicht, wie ich sie mit mehreren Indizes zum Laufen bringen kann (oder sogar nur nach Jahr indexieren). Ebenso habe ich mir Fragen wie diese angesehen:Dieses hierbeim Schreiben benutzerdefinierter \citeBefehle, aber ich habe auch Schwierigkeiten zu verstehen, wie diese funktionieren.

Ein manuell indiziertes minimales funktionierendes Beispiel (unter Verwendung von Biblatex und Multind), das die Art von Endergebnis zeigt, nach dem ich suche:

\documentclass{report}

\usepackage{filecontents}
\begin{filecontents*}{testing.bib}
@article{Author2010,
    author="Author, A and Writer, B",
    journal="Slackers Monthly",
    title="An overly long treatise on procrastination",
    year=2010,
    month=jun,
}
@article{Writer2011,
    author="Writer, B and Scribe, C",
    journal="Fake Online Journal",
    title="Waste of time or time of waste: procrastination in a modern society",
    year=2011,
    month=oct,
}
@book{Writer2003,
    author="Writer, B",
    title="Procrastination for dummies",
    year=2003,
    publisher="Procrastination House",
    address="Auckland",
}
\end{filecontents*}

\usepackage[style=authoryear]{biblatex}
\addbibresource{testing}

\usepackage{multind}
\makeindex{authors}
\makeindex{years}

\begin{document}

\chapter{Introductory works}

\section{An overly long treatise on procrastination}

\fullcite{Author2010}
\index{authors}{Author, A!An overly long treatise on procrastination (2010)}
\index{authors}{Writer, B!An overly long treatise on procrastination (2010)}
\index{years}{2010!An overly long treatise on procrastination}

This paper was really useful in telling me how to waste more time rather 
than doing real work.

\section{Waste of time or time of waste: procrastination in a modern society}

\fullcite{Writer2011}
\index{authors}{Writer, B!Waste of time or time of waste: procrastination in a modern society (2011)}
\index{authors}{Scribe, C!Waste of time or time of waste: procrastination in a modern society (2011)}
\index{years}{2011!Waste of time or time of waste: procrastination in a modern society}

Applies post-modern philosophical theory to procrastination.

\section{Procrastination for dummies}

\fullcite{Writer2003}
\index{authors}{Writer, B!Procrastination for dummies (2003)}
\index{years}{2003!Procrastination for dummies}

A classic reference book for anybody starting a research position.

\printbibliography
\printindex{authors}{Author index}
\printindex{years}{Year index}

\end{document}

Und ein Makefile zum Kompilieren:

default:
    xelatex mwe
    bibtex mwe
    xelatex mwe
    xindy -M texindy -M page-ranges -L english -C utf8 authors.idx
    xindy -M texindy -M page-ranges -L english -C utf8 years.idx
    xelatex mwe

Ist dies also mit einem benutzerdefinierten (oder einem integrierten) Zitierbefehl möglich? Oder wäre es besser, ein Skript zu schreiben, um die BibTeX/Biber-Ausgabe zu analysieren und die Eingabe für xindy zu generieren?

Antwort1

Diese Antwort wurde insbesondere im Lichte der scharfsinnigen Kommentare von Audrey aktualisiert.

Ja. Dafür gibt es mehrere Möglichkeiten.

Der folgende Code ist eine Überarbeitung meines ursprünglichen Vorschlags, der (hoffentlich) verschiedene Mängel bei seiner allgemeinen Verwendung behebt. Im Einzelnen:

  • Mein ursprünglicher Code konnte mit leeren Jahren nicht problemlos umgehen, dieser hier schon.

  • Die Syntax meines ursprünglichen Codes multindund die von Ihnen gewählten Indexnamen sind „fest verdrahtet“: In dieser Version befinden sich die Indexnamen in Makros, was bedeutet, dass sie geändert werden können.

  • indexsorttitleIn meinem ursprünglichen Code wurde von den Feldern und kein Gebrauch gemacht indextitle. Dieser hier tut dies wie vorgesehen.

  • Mein ursprünglicher Code konnte Probleme mit bestimmten Makros verursachen (z. B. \TeXin Indextiteln verwendet, wie Audrey richtig bemerkte). Ich hoffe, dass dieser Code diese Probleme richtig behandelt.

An dem von dir angeführten Beispiel ändert das alles nichts – allerdings habe ich zwei weitere Beispieleinträge hinzugefügt, die in der Originalversion falsch oder dumm behandelt worden wären und hier direkt behandelt werden.

Merkwürdigerweise \fullcitescheint die Indizierungsmakros nicht aufgerufen zu werden, weshalb ich verwendet habe \cite; ich vermute, dass es dafür eine Erklärung gibt, aber ich habe keine Zeit, mich näher damit zu befassen.

\documentclass{report}

\usepackage{filecontents}
\begin{filecontents*}{testing.bib}
@article{Author2010,
    author="Author, A and Writer, B",
    journal="Slackers Monthly",
    title="An overly long treatise on procrastination",
    year=2010,
    month=jun,
}
@article{Writer2011,
    author="Writer, B and Scribe, C",
    journal="Fake Online Journal",
    title="Waste of time or time of waste: procrastination in a modern society",
    year=2011,
    month=oct,
}
@book{Writer2003,
    author="Writer, B",
    title="Procrastination for dummies",
    year=2003,
    publisher="Procrastination House",
    address="Auckland",
}
@book{knuth:ct:b,
  hyphenation = {american},
  sortyear = {1986-1},
  sorttitle = {Computers & Typesetting B},
  indexsorttitle = {TeX: The Program},
  author = {Knuth, Donald E.},
  title = {\TeX: The Program},
  shorttitle = {\TeX},
  maintitle = {Computers \& Typesetting},
  volume = {B},
  publisher = {Addison-Wesley},
  location = {Reading, Mass.},
  date = {1986},
  annotation = {The second volume of a five-volume book. Note the
    \texttt{sorttitle} and \texttt{sortyear} fields. Also note the
    \texttt{indexsorttitle} field}
}
@book{yearless,
  author = {Lazy B. Ugger},
  title  = {I Can't Be Bothered with Years},
  publisher = {Equally Lazee},
}
\end{filecontents*}

\usepackage[style=authoryear,indexing=cite]{biblatex}
\addbibresource{testing.bib}
\makeatletter
% For the "years" index, we redefine the ordinary bibmacro
% which indexes titles, so that it indexes into the years
% index instead
\renewbibmacro*{index:title}[2]{%
  \iffieldundef{year}
     {\usebibmacro{index:years}%
      {\index}%
      {\undated}%
      {\thefield{indexsorttitle}}%
      {\thefield{entrykey}}}
    {\usebibmacro{index:years}%
      {\index}%
      {\thefield{year}}%
      {\thefield{indexsorttitle}}%
      {\thefield{entrykey}}}}

\newbibmacro*{index:years}[4]{%
    \begingroup
     \protected@edef\theindexentry{%
      \unexpanded{#1}\yearsindex{#2!#3\actualoperator\unexpanded{\citefield}{#4}{indextitle}}}%
     \theindexentry
     \endgroup}

% For authors we just redefine the field format (so that it
% includes title and year information
\DeclareIndexNameFormat{default}{%
  \iffieldundef{year}
    {\usebibmacro{index:name}%
      {\index}%
      {#1}%
      {#3}%
      {#5}%
      {#7}%
      {\thefield{indexsorttitle}}%
      {\thefield{entrykey}}%
      {}}
   {\usebibmacro{index:name}%
      {\index}%
      {#1}%
      {#3}%
      {#5}%
      {#7}%
      {\thefield{indexsorttitle}}%
      {\thefield{entrykey}}%
      { (\thefield{year})}}}
% ... and modify the relevant bibmacro to add the extra information
\renewbibmacro*{index:name}[8]{%
  \begingroup
  \ifuseprefix
    {\protected@edef\theindexentry{%
       \unexpanded{#1}\authorsindex{%
         \ifblank{#4}{}{#4 }%
         \@firstofone #2% remove spurious braces
         \ifblank{#5}{}{ #5}%
         \ifblank{#3}{}{, #3}%
         \actualoperator
         \ifblank{#4}{}{\MakeCapital{#4} }%
         #2%
         \ifblank{#5}{}{ #5}%
         \ifblank{#3}{}{, #3}!#6
            \actualoperator\unexpanded{\citefield}{indextitle}#8}}}%
    {\protected@edef\theindexentry{%
       \unexpanded{#1}\authorsindex{%
         \@firstofone #2% remove spurious braces
         \ifblank{#5}{}{ #5}%
         \ifblank{#3#4}{}{,}%
         \ifblank{#3}{}{ #3}%
         \ifblank{#4}{}{ #4}!#6\actualoperator
            \unexpanded{\citefield}{#7}{indextitle}#8}}}%
  \theindexentry
  \endgroup}
\makeatother
% redefine this if the index for years is differently named, or if using
% index or imakeidx
\newcommand{\yearsindex}{{years}}

% redefine this if the index for authors is differently named, or if
% using index or imakeidx
\newcommand{\authorsindex}{{authors}}

% undated entries
\newcommand{\undated}{n.d.}

\usepackage{multind}
\makeindex{authors}
\makeindex{years}

\begin{document}

\chapter{Introductory works}

\section{An overly long treatise on procrastination}

\fullcite{Author2010}

This paper was really useful in telling me how to waste more time rather 
than doing real work.

\section{Waste of time or time of waste: procrastination in a modern society}

\cite{Writer2011}

Applies post-modern philosophical theory to procrastination.

\section{Procrastination for dummies}

\cite{Writer2003}

A classic reference book for anybody starting a research position.

\section{The Awkward Squad}

\cite{knuth:ct:b}

An author who uses a title that indexing programs find hard to cope
with, but certainly no procrastinator.

\cite{yearless}

An author so lazy that he cannot be bothered to put a year of publication.


\printbibliography
\printindex{authors}{Author index}
\printindex{years}{Year index}

\end{document}

(Wenn nötig, können Sie BibLatex dazu bringen, sehr komplexe Indizes zu erstellen: Ich habe gerade die erste Version eines Stils fertiggestellt, der viele, viele Indizes erstellen kann (mehr als 33!) und der nicht nur auf der Grundlage von Titelfeldern indiziert, sondern Postnotes verwendet, um Unterelemente festzulegen. Das Einrichten ist nicht aufregend, aber in der aktuellen Version von BibLatex ist es absolut machbar.)

Antwort2

Dank einer Funktionsanfrage von Maieul und Feedback von Paul wurden in biblatex2.3 eine Reihe von Hilfsbefehlen und Makros eingeführt, die die Indizierung erleichtern, insbesondere die Indizierung mit dem Untereintragsoperator !. Beispiel 22 aus der Dokumentation ( 22-indexing-subentry.tex) demonstriert mehrere Indizes mit Untereinträgen unter Verwendung des imakeidxPakets. Hier ist ein ähnliches Beispiel unter Verwendung von multind.

\documentclass{article}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[indexing=cite,style=authoryear,backend=bibtex]{biblatex}

% Define indices
\usepackage{multind}
\makeindex{authors}
\makeindex{years}

% Name indexing directive for names with title subentries
\DeclareIndexNameFormat{name:title}{%
  \iffieldundef{title}
    {\usebibmacro{index:name}{\index{authors}}{#1}{#3}{#5}{#7}}
    {\usebibmacro{index:name:title:year}{\index{authors}}{#1}{#3}{#5}{#7}}}

% Based on index:name:title macro defined in biblatex.def, takes the arguments:
%   {<index command>}{<last name>}{<first name>}{<first initials>}{<last name prefix>}
% The index:name:subentry macro (also defined in biblatex.def) takes two more:
%   {<plain entry>}{<formatted entry>}
% and forms the subentry: !<plain entry>@<formatted entry>
\newbibmacro*{index:name:title:year}[5]{%
  \iffieldundef{year}
    {\usebibmacro{index:name:title}{#1}{#2}{#3}{#4}{#5}}
    {\usebibmacro{index:name:subentry}{#1}{#2}{#3}{#4}{#5}
       {\thefield{indexsorttitle}}
       {\emph{\csfield{indextitle}}~(\thefield{labelyear})}}}

% Title indexing directive for years with title subentries
\DeclareIndexFieldFormat{year:title}{%
  \iffieldundef{year}
    {\usebibmacro{index:entry}{\index{years}}{%
       \mkbibindexentry{0}{Not dated}%
       \subentryoperator%
       \mkbibindexfield{\thefield{indexsorttitle}}{\emph{#1}}}}
    {\usebibmacro{index:entry}{\index{years}}{%
       \thefield{year}\subentryoperator%
       \mkbibindexfield{\thefield{indexsorttitle}}{\emph{#1}}}}}

\renewbibmacro*{citeindex}{%
  \ifciteindex
    {\indexnames[name:title]{author}%
     \indexfield[year:title]{indextitle}}
    {}}

% Index entries accessed via \fullcite
\DeclareCiteCommand{\fullcite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usedriver
     {\DeclareNameAlias{sortname}{default}}
     {\thefield{entrytype}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\addbibresource{biblatex-examples.bib}

\begin{document}
\fullcite{knuth:ct,knuth:ct:a,knuth:ct:c,knuth:ct:d}
\cite{aristotle:anima,aristotle:poetics,aristotle:physics,aristotle:rhetoric}
\printbibliography
\raggedright
\printindex{authors}{Author and Title Index}
\printindex{years}{Year and Title Index}
\end{document}

Antwort3

Ich verwende ein Skript Python für ein ähnliches Problemhttp://geekographie.maieul.net/Un-index-des-sources-primaires-3.

Ich eröffne einfach ein Ticket, um nach der Möglichkeit zu fragen, mehr als ein Feld zu indizieren.https://github.com/plk/biblatex/issues/31

verwandte Informationen