著者と年による参照の自動索引付け

著者と年による参照の自動索引付け

私は文献レビューを書いていますが、著者と出版年(つまり、2つのインデックス)。適切な\index{}コマンドを手動で入力することもできますが、これは biblatex によって自動的に処理できるもののようです。これにより、メンテナンスがはるかに容易になります。これは、今後数年間、研究を進めるにつれてレビューを最新の状態に保つつもりであるため、重要な考慮事項です。

私はbiblatexに組み込まれている索引オプションを試してみましたが、複数の索引(あるいは年ごとの索引だけでも)でどのように機能させるかわかりません。同様に、次のような質問も見てきました。これですカスタム\citeコマンドの作成については理解していますが、それがどのように機能するかも理解できていません。

私が求めている最終結果を示す、手動でインデックス付けされた最小限の動作例 (biblatex と multind を使用) を以下に示します。

\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}

そしてそれをコンパイルするための Makefile は次の通りです:

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

では、カスタム cite コマンド (または組み込みコマンド) を使用してこれを実現することは可能でしょうか? または、BibTeX/biber 出力を解析して xindy への入力を生成するスクリプトを作成したほうがよいでしょうか?

答え1

この回答は、特にオードリーの鋭いコメントを考慮して更新されました。

はい。これを行うにはいくつかの方法があります。

以下のコードは私の最初の提案を改訂したもので、一般的な使用におけるさまざまな欠陥を修正したものになっています (そう願っています)。具体的には、次のようになります。

  • 私の元のコードでは空の年を適切に処理できませんでしたが、これは処理します。

  • 私の元のコードにはmultind、構文と選択したインデックス名が「ハードワイヤード」されています。このバージョンでは、インデックス名はマクロ内にあるため、変更できます。

  • indexsorttitle私の元のコードでは、フィールドとフィールドを使用していませんでしたindextitleが、このコードでは、当然のことながら、フィールドを使用します。

  • 私の元のコードは、特定のマクロ (たとえば\TeX、Audrey が適切に指摘したように、indextitles で使用されるマクロ) で問題を引き起こす可能性があります。これで、それらの問題が適切に処理されると思います。

あなたが示した例では、これによって何も変わることはありませんが、元のバージョンでは誤ってまたは不適切に処理されていた 2 つの例エントリをさらに追加し、これを直接処理します。

奇妙なことに、\fullciteインデックス マクロを呼び出さないようです。そのため、 を使用しました\cite。おそらくそれには説明があると思いますが、調べる時間がありません。

\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}

(必要な場合は、biblatex に非常に複雑な索引付けを行わせることができます。私は、非常に多くの索引 (33 以上!) を作成できるスタイルの最初のバージョンを完成させました。このスタイルでは、タイトル フィールドだけでなく、ポストノートを使用してサブ項目を設定します。設定はそれほど面倒ではありませんが、biblatex の現状では絶対に実行可能です。)

答え2

Maieul の機能リクエストと Paul のフィードバックのおかげで、biblatex2.3 ではインデックス作成、特にサブエントリ演算子を使用したインデックス作成を支援するための補助コマンドとマクロがいくつか導入されました!。ドキュメントの例 22 ( 22-indexing-subentry.tex) は、 パッケージを使用したサブエントリを持つ複数のインデックスを示していますimakeidx。 を使用した同様の例を次に示します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}

答え3

私は同様の問題にスクリプトPythonを使用していますhttp://geekographie.maieul.net/Un-index-des-sources-primaires-3

複数のフィールドにインデックスを付ける可能性について問い合わせるためにチケットを開きます。https://github.com/plk/biblatex/issues/31

関連情報