我有一个设置,其中我使用额外的 BibTeX 字段来记录索引中使用的作者/编辑者姓名(authauthor、autheditor)。请参阅从 biblatex 中索引的另一个字段获取名称。由于某些我不明白的原因,这在普通 \cite 命令下有效,但在使用 \citeauthor 时失败。我重新定义了citeindex
也许这不需要\citeauthor
。
% call with
% xelatex debug-biber-authorindex.tex
% biber debug-biber-authorindex
% xelatex debug-biber-authorindex.tex
% makeindex -o debug-biber-authorindex.ind debug-biber-authorindex.idx
% xelatex debug-biber-authorindex.tex
\documentclass{article}
\begin{filecontents}{\jobname.bib}
@phdthesis{Fokkens2014a,
authauthor = {Fokkens, Antske},
author = {Fokkens, Antske Sibelle},
school = {Department of Computational Linguistics, Universität des Saarlandes},
sortname = {Fokkens, Antske},
title = {Enhancing Empirical Research for Linguistically Motivated Precision Grammars},
year = {2014}}
\end{filecontents}
\begin{filecontents}{langsci.dbx}
\DeclareDatamodelFields[type=list, datatype=name]{
authauthor,autheditor,sortname}
\DeclareDatamodelEntryfields{authauthor,autheditor,sortname}
% for URLs like jstor URLs and MIT handle URLs, ACL antology
\DeclareDatamodelFields[type=field,datatype=literal]{
stableurl}
\DeclareDatamodelEntryfields{stableurl}
% We also want to have this for books. Otherwise
%
% biber --validate-datamodel main
%
% complains.
\DeclareDatamodelEntryfields[book,proceedings]{
booktitle}
% just to get rid of warnings, authors keep supplying publishers with article entries
% St. Mü, 2021-02-11
\DeclareDatamodelEntryfields[article]{
publisher}
% St. Mü. 2021-02-11
% our maintainance field. It records whether an item was reviewed or not.
%
\DeclareDatamodelFields[type=field,datatype=literal]{checked}
\DeclareDatamodelEntryfields{checked}
% \DeclareDatamodelFields[type=field,datatype=literal]{checkedseries}
% \DeclareDatamodelEntryfields{checkedseries}
% \DeclareDatamodelFields[type=field,datatype=literal]{checkednumber}
% \DeclareDatamodelEntryfields{checkednumber}
% bibdesk stuff
\DeclareDatamodelFields[type=field,datatype=literal]{
bdsk-url-1,
bdsk-url-2,
bdsk-file-3,
date-added,
date-modified,
read}
\DeclareDatamodelEntryfields{
bdsk-url-1,
bdsk-url-2,
bdsk-file-3,
date-added,
date-modified,
read}
% opt fields
\DeclareDatamodelFields[type=field,datatype=literal]{
%optdate,
opteditor,
optchapter,
optisbn,
optissn,
optmonth,
optpublisher,
optschool,
opturl,
optyear}
\DeclareDatamodelEntryfields{
%optdate,
opteditor,
optchapter,
optisbn,
optissn,
optmonth,
optpublisher,
optschool,
opturl}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ResetDatamodelConstraints
% St. Mü. 2021-02-10
\DeclareDatamodelConstraints[
article,
book,
inbook,
bookinbook,
suppbook,
booklet,
collection,
incollection,
suppcollection,
manual,
misc,
mvbook,
mvcollection,
online,
patent,
periodical,
suppperiodical,
proceedings,
inproceedings,
reference,
inreference,
report,
set,
thesis,
unpublished]{
\constraint[type=mandatory]{
\constraintfieldsxor{
\constraintfield{date}
\constraintfield{year}
}
\constraintfield{checked} % uncomment for checking
}
% if there is an URL then there should be a urldate field.
\constraint[type=conditional]{
\antecedent[quantifier=one]{
\constraintfield{url}
}
% biber/biblatex splits urldate into urlyear,urlmoth,ulrday
\consequent[quantifier=all]{
\constraintfield{urlyear}
\constraintfield{urlmonth}
\constraintfield{urlday}
}
}
}
\DeclareDatamodelConstraints[
article,
% book,
inbook,
% bookinbook,
% suppbook,
% booklet,
% collection,
incollection,
suppcollection,
% manual,
% misc,
% mvbook,
% mvcollection,
% online,
% patent,
% periodical,
% suppperiodical,
% proceedings,
inproceedings%,
% reference,
% inreference,
% report,
% set,
% thesis,
% unpublished
]{
\constraint[type=mandatory]{
\constraintfield{pages} % uncomment for checking
}
}
\DeclareDatamodelConstraints[set]{
\constraint[type=mandatory]{
\constraintfield{entryset}
}
}
\DeclareDatamodelConstraints[article]{
\constraint[type=mandatory]{
\constraintfield{author}
\constraintfield{journaltitle}
\constraintfield{title}
% st. mü. 2021-02-13 yes, we want volume and number
% if there is no number, the number field should be filled with "none". This will be surpressed by
% an output filter.
\constraintfield{volume}
\constraintfield{number}
\constraintfield{pages}
}
}
\DeclareDatamodelConstraints[book,mvbook,mvcollection,mvreference,incollection]{
\constraint[type=mandatory]{
\constraintfield{title}
% Those books that are not in a series have the value none. St. Mü. 2021.02.11
% The value is suppressed by an outputfilter declaration for biblatex
\constraintfield{series}
}
% if there is a series, there has to be a number. books without a number get the value none.
% The value none is suppressed by an output filter declaration for biblatex
\constraint[type=conditional]{
\antecedent[quantifier=one]{
\constraintfield{series}
}
\consequent[quantifier=all]{
\constraintfield{number}
}
}
}
\DeclareDatamodelConstraints[inbook,bookinbook,suppbook]{
\constraint[type=mandatory]{
\constraintfield{author}
\constraintfield{title}
\constraintfield{booktitle}
\constraintfield{publisher}
\constraintfieldsxor{
\constraintfield{address}
\constraintfield{location}
}
}
}
\DeclareDatamodelConstraints[booklet]{
\constraint[type=mandatory]{
\constraintfieldsor{
\constraintfield{author}
\constraintfield{editor}
}
\constraintfield{title}
}
}
\DeclareDatamodelConstraints[collection,reference]{
\constraint[type=mandatory]{
\constraintfield{editor}
\constraintfield{title}
\constraintfield{publisher}
\constraintfieldsxor{
\constraintfield{address}
\constraintfield{location}
}
}
}
\DeclareDatamodelConstraints[incollection,suppcollection,inreference]{
\constraint[type=mandatory]{
\constraintfield{author}
\constraintfield{editor}
\constraintfield{title}
\constraintfield{booktitle}
%\constraintfield{series}
%\constraintfield{number}
\constraintfield{publisher}
\constraintfieldsxor{
\constraintfield{address}
\constraintfield{location}
}
}
}
\DeclareDatamodelConstraints[dataset]{
\constraint[type=mandatory]{
\constraintfield{title}
}
}
\DeclareDatamodelConstraints[manual]{
\constraint[type=mandatory]{
\constraintfield{title}
}
}
\DeclareDatamodelConstraints[misc,software]{
\constraint[type=mandatory]{
\constraintfield{title}
}
}
\DeclareDatamodelConstraints[online]{
\constraint[type=mandatory]{
\constraintfield{title}
\constraintfieldsor{
\constraintfield{url}
\constraintfield{doi}
\constraintfield{eprint}
}
}
}
\DeclareDatamodelConstraints[patent]{
\constraint[type=mandatory]{
\constraintfield{author}
\constraintfield{title}
\constraintfield{number}
}
}
\DeclareDatamodelConstraints[periodical]{
\constraint[type=mandatory]{
\constraintfield{editor}
\constraintfield{title}
}
}
\DeclareDatamodelConstraints[proceedings,mvproceedings]{
\constraint[type=mandatory]{
\constraintfield{title}
\constraintfield{editor}
\constraintfield{publisher}
\constraintfieldsxor{
\constraintfield{address}
\constraintfield{location}
}
}
}
\DeclareDatamodelConstraints[inproceedings]{
\constraint[type=mandatory]{
\constraintfield{author}
\constraintfield{editor}
\constraintfield{title}
\constraintfield{booktitle}
\constraintfield{publisher}
\constraintfieldsxor{
\constraintfield{address}
\constraintfield{location}
}
}
}
\DeclareDatamodelConstraints[report]{
\constraint[type=mandatory]{
\constraintfield{author}
\constraintfield{title}
\constraintfield{type}
\constraintfield{institution}
}
}
\DeclareDatamodelConstraints[thesis]{
\constraint[type=mandatory]{
\constraintfield{author}
\constraintfield{title}
\constraintfield{type}
\constraintfield{institution}
}
}
\DeclareDatamodelConstraints[unpublished]{
\constraint[type=mandatory]{
\constraintfield{author}
\constraintfield{title}
}
}
\DeclareDatamodelConstraints{
\constraint[type=data, datatype=isbn]{
\constraintfield{isbn}
}
\constraint[type=data, datatype=issn]{
\constraintfield{issn}
}
\constraint[type=data, datatype=ismn]{
\constraintfield{ismn}
}
\constraint[type=data, datatype=pattern, pattern=\regexp{(?:sf|sm|sn|pf|pm|pn|pp)}]{
\constraintfield{gender}
}
}
\end{filecontents}
\usepackage[
natbib=true,
style=langsci-unified,
citestyle=langsci-unified,
datamodel=langsci, % add authauthor and autheditor as possible fields to bibtex entries
backend=biber,
indexing=cite,
]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{index}
\makeindex
\renewbibmacro*{citeindex}{%
\ifciteindex
{\iffieldequalstr{labelnamesource}{shortauthor} % If biblatex uses shortauthor as the label of a bibitem
{\ifnameundef{authauthor} % we check whether there is something in authauthor
{\indexnames{author}} % if not, we use author
{\indexnames{authauthor}}} % if yes, we use authauthor
{\iffieldequalstr{labelnamesource}{author} % if biblatex uses author we similarly test for
% authauthor and use this field
{\ifnameundef{authauthor}% if defined use authauthor
{\indexnames{author}}
{\indexnames{authauthor}}} % if defined use this field
{\iffieldequalstr{labelnamesource}{shorteditor} % same for editor
{\ifnameundef{autheditor}
{\indexnames{editor}}
{\indexnames{autheditor}}}
{\indexnames{labelname}}}}} % as a fallback we index on whatever biblatex used.
{}}
\begin{document}
Page 1.
\cite{Fokkens2014a}
\newpage
Page 2.
\cite{Fokkens2014a}
\newpage
Page 3.
\citeauthor{Fokkens2014a}
\newpage
Page 4.
\cite{Fokkens2014a}
\printbibliography
\printindex
\end{document}
答案1
langsci-unified.cbx
定义\citeauthor
如下
\DeclareCiteCommand{\citeauthor}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\ifciteindex
{\indexnames{labelname}}
{}%
\printtext[bibhyperref]{\printnames{labelname}}}
{\multicitedelim}
{\usebibmacro{postnote}}
此定义基于biblatex.def
\DeclareCiteCommand{\citeauthor}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\ifciteindex
{\indexnames{labelname}}
{}%
\printnames{labelname}}
{\multicitedelim}
{\usebibmacro{postnote}}
因此,这些\citeauthor
s 具有明确的
\ifciteindex
{\indexnames{labelname}}
{}%
并且不要使用\usebibmacro{citeindex}
。(我猜想这个想法citeindex
通常会将名称和标题都发送到索引,但对于\citeauthor
索引名称来说是只合适的。)
您可以更改该定义以供使用citeindex
。
\DeclareCiteCommand{\citeauthor}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\printnames{labelname}}}
{\multicitedelim}
{\usebibmacro{postnote}}