我使用 biblatex(用于我的简历)列出我的所有出版物,使用单独的 bib 文件(lastname.bib)。我使用带有 biber 后端的 biblatex。
我要添加一个部分来列出我的所有合著者。有什么方法可以自动完成此操作吗?
答案1
使用 Sourceforge 的最新biblatex
3.3 和biber
2.4 开发版本。新的映射功能允许循环和创建新条目,因此可以将名称字段拆分为专用的条目类型以便正确打印:
\documentclass{article}
\usepackage{filecontents}
% Declare the coauthor name field
\begin{filecontents}{\jobname.dbx}
\DeclareDatamodelFields[type=list, datatype=name, label=true]{coauthor}
\DeclareDatamodelEntrytypes{coauthor}
\DeclareDatamodelEntryfields[coauthor]{coauthor}
\end{filecontents}
\begin{filecontents}{\jobname.bib}
@ARTICLE{test1,
AUTHOR = {Arthur Smith and James Jones and Bill Smiley and Jake Wrath},
JOURNALTITLE = {A Journal},
YEAR = {2010}
}
@ARTICLE{test2,
AUTHOR = {Philippa Smyth and Arthur Smith and Bill Likely},
JOURNALTITLE = {Another Journal},
YEAR = {2011}
}
@ARTICLE{test3,
AUTHOR = {Arthur Smith},
JOURNALTITLE = {The Best Journal},
YEAR = {2013}
}
@ARTICLE{test4,
AUTHOR = {Philippa Smyth and Arthur Smith and James Jones},
JOURNALTITLE = {Again Another Journal},
YEAR = {2014}
}
\end{filecontents}
\usepackage[style=authoryear,datamodel=\jobname]{biblatex}
\addbibresource{\jobname.bib}
% 1. First, check if the author list contain me, here, "Arthur Smith"
% 2. Copy the author field to a temporary field "coauthortext". We don't need
% datamodel declarations for this as this will be deleted after use and
% will never get anywhere near code that queries the data model.
% 3. Remove me (Arthur Smith) from this temporary copy of the author list
% 4. Turn the resulting field into a comma-separated list
% 5. Loop over this comma-separated list, creating new entries of type
% "coauthor" each with a "coauthor" name list field containing the data
% from the loop variable
% 6. Remove the temporary author field copy "coauthortext"
%
% The special $MAPLOOP variable holds each value of the csv field name by
% the "foreach" option on the \map macro.
% The special $MAPUNIQ variable is a random string generated automatically
% at the beginning of each \map section. This can be when you need a unique
% string as here because entrykeys should be new unique.
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite]{
\step[fieldsource=author,
match=\regexp{Arthur\s+Smith}, final]
\step[fieldsource=author,
notmatch=\regexp{^Arthur\s+Smith$}, final]
\step[fieldsource=author, fieldset=coauthortext, origfieldval]
\step[fieldsource=coauthortext,
match=\regexp{Arthur\s+Smith\s+and\s+},
replace={}]
\step[fieldsource=coauthortext,
match=\regexp{\s+and\s+Arthur\s+Smith},
replace={}]
\step[fieldsource=coauthortext,
match=\regexp{\s+and\s+},
replace={,}]
}
\map[overwrite, foreach=coauthortext]{
\step[fieldsource=coauthortext, match=\regexp{.}, final]
\step[entrynew=\regexp{$MAPUNIQ}, entrynewtype=coauthor]
\step[entrytarget=\regexp{$MAPUNIQVAL}, fieldset=coauthor, fieldvalue=\regexp{$MAPLOOP}]
\step[entrytarget=\regexp{$MAPUNIQVAL}, fieldset=options, fieldvalue=skipbib]
}
\map[overwrite]{
\step[fieldsource=coauthortext, null]
}
}
}
% Sort the biblist by coauthor name
\DeclareSortingScheme{coauthor}{
\sort{
\field{coauthor}
}
}
% Driver to print the biblist items
\DeclareBibliographyDriver{coauthor}{%
\printnames{coauthor}}
% bibcheck to strip duplicates
\defbibcheck{coauthor}{%
\ifcsdef{\strname{coauthor}}
{\skipentry}
{\savenamecs{coauthor}{\strname{coauthor}}}}
% Simple bibenvironment to print the biblist
\defbibenvironment{coauthor}
{\list{}
{\setlength{\leftmargin}{\bibhang}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endlist}
{\item}
\begin{document}
\nocite{*}
\printbibliography
% This will automatically use the "coauthor" sorting scheme/biblist/driver etc.
\printbiblist[title=CoAuthors]{coauthor}
\end{document}
答案2
我认为我通过作者索引找到了答案。我尝试在下面包含 MWE,但我可能添加了几行不必要的内容。
\documentclass{article}
\usepackage[indexing=true,maxnames=99,style=authoryear,datamodel=\jobname]{biblatex}
\usepackage{filecontents}
\usepackage{imakeidx}
\makeindex[program=makeindex,options=-s mystyle.ist,title=List of Co-Authors]
\usepackage{letltxmacro}
% Declare the coauthor name field
\begin{filecontents}{\jobname.dbx}
\DeclareDatamodelFields[type=list, datatype=name]{coauthor}
\DeclareDatamodelEntryfields{coauthor}
\end{filecontents}
% Required to remove the page number after the author in the index
\makeatletter
\let\mygobble\@gobble
\LetLtxMacro\OldIndex\index
\renewcommand{\index}[1]{\OldIndex{#1|mygobble}}
\makeatother
\begin{filecontents*}{mystyle.ist}
quote '+'
delim_0 " "
delim_1 " "
delim_2 " "
delim_n " "
\end{filecontents*}
% I use a slightly more general bib, with a single author publication, and co-authors over several papers.
\begin{filecontents}{\jobname.bib}
@ARTICLE{test1,
AUTHOR = {Arthur Smith and James Jones and Bill Smiley and Jake Wrath},
JOURNALTITLE = {A Journal},
YEAR = {2010}
}
@ARTICLE{test2,
AUTHOR = {Philippa Smyth and Arthur Smith and Bill Likely},
JOURNALTITLE = {Another Journal},
YEAR = {2011}
}
@ARTICLE{test3,
AUTHOR = {Arthur Smith},
JOURNALTITLE = {The Best Journal},
YEAR = {2013}
}
@ARTICLE{test4,
AUTHOR = {Philippa Smyth and Arthur Smith and James Jones},
JOURNALTITLE = {Again Another Journal},
YEAR = {2014}
}
\end{filecontents}
\addbibresource{\jobname.bib}
% Create a "coauthor" name list which is a copy of the "author" name
% list, minus oneself (assuming you are "Arthur Smith" and this is how
% your name always appears in the .bib - you can always make more
% sophisticated regexps if there is name variation)
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite]{
\step[fieldsource=author,
match=\regexp{Arthur\s+Smith}, final]
\step[fieldsource=author, fieldset=coauthor, origfieldval]
\step[fieldsource=coauthor,
match=\regexp{Arthur\s+Smith\s+and\s+},
replace={}]
\step[fieldsource=coauthor,
match=\regexp{\s+and\s+Arthur\s+Smith},
replace={}]
\step[fieldsource=coauthor,
match=\regexp{Arthur\s+Smith},
replace={}]
}
}
}
% Sort the biblist by coauthor name
\DeclareSortingScheme{coauthor}{\sort{\field{coauthor}}}
\DeclareIndexNameFormat{default}{\usebibmacro{index:name}{\index}{#1}{#3}{#5}{#7}}
\renewbibmacro*{bibindex}{\ifbibindex{\indexnames{coauthor}}{}}
% Driver to print the biblist items
\DeclareBibliographyDriver{coauthor}{\printnames{coauthor}}
% Simple bibenvironment to print the biblist
\defbibenvironment{coauthor}{\list{}{}}{\endlist}{\item}
\begin{document}
\nocite{*}
\printbibliography
\raggedright
\printindex
\end{document}