
Estou escrevendo uma revisão de literatura e gostaria de adicionar índices tanto para autores quanto para ano de publicação (ou seja, doisseparadoíndices). Agora, eu poderia inserir manualmente os \index{}
comandos apropriados, mas parece que isso pode ser tratado automaticamente pelo biblatex. Certamente tornaria a manutenção muito mais fácil, uma consideração importante, já que pretendo manter a revisão atualizada durante os próximos anos, à medida que progrido em minha pesquisa.
Tenho brincado com a opção de indexação incorporada ao biblatex, mas não consigo ver como fazê-lo funcionar com vários índices (ou mesmo indexar apenas por ano). Da mesma forma, tenho analisado questões comoEstesobre escrever \cite
comandos personalizados, mas estou lutando para ver como eles funcionam também.
Um exemplo de trabalho mínimo indexado manualmente (usando biblatex e multind) que mostra o tipo de resultado final que procuro:
\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}
E um Makefile para compilá-lo:
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
Então, isso é possível com um comando de citação personalizado (ou um comando integrado)? Ou seria melhor escrever um script para analisar a saída do BibTeX/biber para gerar a entrada para o xindy?
Responder1
Esta resposta foi atualizada à luz, principalmente, dos comentários perspicazes de Audrey.
Sim. Existem várias maneiras de fazer isso.
O código abaixo é uma revisão da minha sugestão original, que (espero) corrige diversas deficiências em seu uso geral. Especificamente:
Meu código original não lidava bem com anos vazios: isso sim.
A sintaxe do meu código original "hardwired"
multind
e os nomes dos índices escolhidos: nesta versão os nomes dos índices estão em macros, o que significa que podem ser alterados.Meu código original não fez uso dos campos
indexsorttitle
eindextitle
: isso faz, como deveria.Meu código original poderia causar problemas com certas macros (por exemplo,
\TeX
usadas em títulos de índice, como Audrey apontou corretamente. Isso lida com isso corretamente, espero.
No exemplo que você deu, nada disso muda nada - mas adicionei mais duas entradas de exemplo que a versão original teria tratado de forma errada ou estúpida, e isso trata diretamente.
Estranhamente, \fullcite
não parece chamar as macros de indexação, e é por isso que usei \cite
; Ouso dizer que há uma explicação para isso, mas não tenho tempo para me aprofundar no assunto.
\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}
(Se precisar, você pode persuadir o biblatex a fazer uma indexação muito complexa: acabei de completar a primeira versão de um estilo que pode produzir muitos, muitos índices (mais de 33!), e cujos índices não são baseados apenas no título campos, mas usa postnotes para definir subitens. Não é emocionante configurar, mas é absolutamente viável como o biblatex está.)
Responder2
Graças a uma solicitação de recurso de Maieul e ao feedback de Paul, vários comandos e macros auxiliares foram introduzidos no biblatex
2.3 para auxiliar na indexação, particularmente na indexação com o operador de subentrada !
. O exemplo 22 da documentação ( 22-indexing-subentry.tex
) demonstra múltiplos índices com subentradas usando o imakeidx
pacote. Aqui está um exemplo semelhante usando 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}
Responder3
Eu uso um script python para um problema semelhantehttp://geekographie.maieul.net/Un-index-des-sources-primaires-3.
Acabei de abrir um ticket pedindo a possibilidade de indexar mais de um campo.https://github.com/plk/biblatex/issues/31