
Estoy escribiendo una revisión de la literatura y me gustaría agregar índices tanto para los autores como para el año de publicación (es decir, dosseparadoíndices). Ahora, podría ingresar manualmente los \index{}
comandos apropiados, pero parece que esto es algo que biblatex podría manejar automáticamente. Sin duda, facilitaría mucho el mantenimiento, una consideración importante ya que tengo la intención de mantener la revisión actualizada durante los próximos años a medida que avance en mi investigación.
He estado jugando con la opción de indexación que está integrada en biblatex pero no veo cómo hacer que funcione con múltiples índices (o incluso indexar solo por año). De manera similar, he estado analizando preguntas comoÉstesobre escribir \cite
comandos personalizados, pero también me cuesta ver cómo funcionan.
Un ejemplo de trabajo mínimo indexado manualmente (usando biblatex y multind) que muestra el tipo de resultado final que busco:
\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}
Y un Makefile para compilarlo:
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
Entonces, ¿es posible lograr esto con un comando de cita personalizado (o uno integrado)? ¿O sería mejor escribir un script para analizar la salida de BibTeX/biber para generar la entrada a xindy?
Respuesta1
Esta respuesta se ha actualizado a la luz, en particular, de los perspicaces comentarios de Audrey.
Sí. hay muchas maneras de hacer esto.
El siguiente código es una revisión de mi sugerencia original, que (espero) corrige varias deficiencias en su uso general. Específicamente:
Mi código original no trataba con gracia los años vacíos: esto sí.
Mi código original "cableó"
multind
la sintaxis y los nombres de índice elegidos: en esta versión, los nombres de índice están en macros, lo que significa que se pueden cambiar.Mi código original no hacía uso de los campos
indexsorttitle
yindextitle
: esto lo hace, como debería.Mi código original podría causar problemas con ciertas macros (por ejemplo,
\TeX
utilizadas en títulos de índice, como Audrey señaló correctamente. Espero que esto las maneje correctamente.
En el ejemplo que diste, nada de esto cambia nada, pero agregué dos entradas de ejemplo más que la versión original habría manejado de manera incorrecta o estúpida, y esto se maneja directamente.
Curiosamente, \fullcite
no parece llamar a las macros de indexación, razón por la cual he usado \cite
; Me atrevo a decir que hay una explicación para esto, pero no tengo tiempo para profundizar en ello.
\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}
(Si es necesario, puede convencer a biblatex para que realice una indexación muy compleja: acabo de completar la primera versión de un estilo que puede producir muchos, muchos índices (¡más de 33!) y que indexa no solo en el título. campos, pero usa notas posteriores para configurar subelementos. No es emocionante configurarlo, pero es absolutamente factible tal como está biblatex.)
Respuesta2
Gracias a una solicitud de función de Maieul y los comentarios de Paul, se introdujeron varios comandos auxiliares y macros en biblatex
2.3 para ayudar a la indexación, particularmente la indexación con el operador de subentrada !
. El ejemplo 22 de la documentación ( 22-indexing-subentry.tex
) muestra múltiples índices con subentradas usando el imakeidx
paquete. Aquí hay un ejemplo similar 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}
Respuesta3
Utilizo un script Python para un problema similar.http://geekographie.maieul.net/Un-index-des-sources-primaires-3.
Simplemente abro un ticket para solicitar la posibilidad de indexar más de un campo.https://github.com/plk/biblatex/issues/31