我用来biblatex
编制作者索引。
有些作者以几个不同的名字出版作品,因此,有些 bibfile 条目具有不同的作者/编辑者姓名,我想将这些条目合并到作者索引中。(基本上,“Doe, John Jack”和“Doe, John”应该合并为“Doe, John Jack”。)
有一个indextitle
字段用于索引的备用标题。有什么想法可以让作者/编辑姓名也使用类似的功能吗?谢谢大家!
编辑:需要使用backend=bibtex
。(抱歉之前没有说清楚。)
超简单示例(目前):
\documentclass{scrartcl}
\usepackage{filecontents}
\begin{filecontents*}{bb.bib}
@article{doe1979,
Author = {Doe, John},
Indexauthor = {Doe, John Jack},
Journal = {Journal of Everything},
Pages = {163--176},
Title = {Great Stuff},
Volume = {7},
Year = {1979}}
@article{doe1981,
Author = {Doe, John Jack},
Indexauthor = {Doe, John Jack},
Journal = {Journal of Nothing},
Pages = {164--178},
Title = {More Great Stuff},
Volume = {4},
Year = {1981}}
\end{filecontents*}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Arial Unicode MS}
\usepackage[style=authoryear,indexing=cite,backend=bibtex]{biblatex}
\addbibresource{bb.bib}
\usepackage{makeidx}
\makeindex
\begin{document}
\cite{doe1979,doe1981}
\printbibliography
\printindex
\end{document}
答案1
以下解决方案使用 Biber 后端,因为我们需要创建一个新字段(indexname
)。
类似于shortname
,sortname
我们的新领域被称为indexname
。
首先,我们需要让 Biber 知道这个新字段biblatex
。创建一个.dbx
包含以下内容的文件
\DeclareDatamodelFields[type=list, datatype=name]{indexname}
\DeclareDatamodelEntrytypes{indexname}
\DeclareDatamodelEntryfields{indexname}
并将其放在 LaTeX 可以找到的地方(在下面的 MWE 中,这通过 完成filecontents
)。如果您现在加载biblatex
,请使用选项加载它datamodel
,并给出 的文件名.dbx
(不带扩展名),在 MWE 中将是
\usepackage[style=authoryear,indexing=cite,backend=biber,datamodel=\jobname]{biblatex}
(请注意,正如所见,我们使用 Biber 而不是 BibTeX backend=biber
)。
然后我们只需让索引宏使用indexname
\renewbibmacro*{citeindex}{%
\ifciteindex
{\ifnameundef{indexname}
{\indexnames{labelname}}
{\indexnames{indexname}}%
\indexfield{indextitle}}
{}}
\renewbibmacro*{bibindex}{%
\ifbibindex
{\ifnameundef{indexname}
{\indexnames{labelname}}
{\indexnames{indexname}}%
\indexfield{indextitle}}
{}}
一切就绪。labelname
如果没有indexname
提供,索引将恢复为标准 s。
正如 PLK 所建议的,让 Biberindexname
自己填充可能是一个好主意
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=author, match=\regexp{Doe,\s+John(\s+Jack)?|John(\s+Jack)?\+*Doe}, final]
\step[fieldset=indexname, fieldvalue={Doe, John Jack}]
}
}
}
平均能量损失
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{doe1979,
Author = {Doe, John},
indexname = {Doe, John Jack},
Journal = {Journal of Everything},
Pages = {163--176},
Title = {Great Stuff},
Volume = {7},
Year = {1979}}
@article{doe1981,
Author = {Doe, John Jack},
indexname = {Doe, John Jack},
Journal = {Journal of Nothing},
Pages = {164--178},
Title = {More Great Stuff},
Volume = {4},
Year = {1981}}
\end{filecontents*}
\begin{filecontents}{\jobname.dbx}
\DeclareDatamodelFields[type=list, datatype=name]{indexname}
\DeclareDatamodelEntrytypes{indexname}
\DeclareDatamodelEntryfields{indexname}
\end{filecontents}
\usepackage[style=authoryear,indexing=cite,backend=biber,datamodel=\jobname]{biblatex}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\usepackage{makeidx}
\makeindex
\renewbibmacro*{citeindex}{%
\ifciteindex
{\ifnameundef{indexname}
{\indexnames{labelname}}
{\indexnames{indexname}}%
\indexfield{indextitle}}
{}}
\renewbibmacro*{bibindex}{%
\ifbibindex
{\ifnameundef{indexname}
{\indexnames{labelname}}
{\indexnames{indexname}}%
\indexfield{indextitle}}
{}}
\begin{document}
\cite{doe1979,doe1981,sigfridsson}
\printbibliography
\printindex
\end{document}
如果您使用 BibTeX,则无法使用花哨的数据模型功能。那么最简单的方法可能是使用自定义namea
字段代替indexname
,不需要数据模型(.dbx
)文件。但您无法使用上面的源映射功能。
BibTeX 的 MWE
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{doe1979,
Author = {Doe, John},
namea = {Doe, John Jack},
Journal = {Journal of Everything},
Pages = {163--176},
Title = {Great Stuff},
Volume = {7},
Year = {1979}}
@article{doe1981,
Author = {Doe, John Jack},
namea = {Doe, John Jack},
Journal = {Journal of Nothing},
Pages = {164--178},
Title = {More Great Stuff},
Volume = {4},
Year = {1981}}
\end{filecontents*}
\usepackage[style=authoryear,indexing=cite,backend=bibtex]{biblatex}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\usepackage{makeidx}
\makeindex
\renewbibmacro*{citeindex}{%
\ifciteindex
{\ifnameundef{namea}
{\indexnames{labelname}}
{\indexnames{namea}}%
\indexfield{indextitle}}
{}}
\renewbibmacro*{bibindex}{%
\ifbibindex
{\ifnameundef{namea}
{\indexnames{labelname}}
{\indexnames{namea}}%
\indexfield{indextitle}}
{}}
\begin{document}
\cite{doe1979,doe1981,sigfridsson}
\printbibliography
\printindex
\end{document}