假设我使用标准风格的 BibLaTeXauthoryear
或者authoryear-comp
。
然后给出一个引用命令,例如 \parencite{A, B, C}(或任何其他标准 Biblatex 引用命令),我希望根据相应参考书目条目中的给定字段(例如作者字段)是否包含给定字符串(例如某人的姓氏)对生成的引用进行不同的排版。
梅威瑟:
\documentclass{article}
\usepackage{filecontents}
\usepackage[backend=biber,style = authoryear-comp]{biblatex}
\usepackage[colorlinks=true, breaklinks, allcolors = blue]{hyperref}
\DeclareSourcemap{%
\maps[datatype=bibtex]{%
\map{%
\step[fieldsource=author, match=Doe, final]%
\step[fieldset=keywords, fieldvalue=doe]%
}%
}%
}
\begin{filecontents}{\jobname.bib}
@Book{p1,
author = "A. U. Thor and John Doe",
title = "A Scientific Article 1",
year = "1975"
}
@Book{p2,
author = "John Doe",
title = "A Scientific Article 2",
year = "1985"
}
@Book{p3,
author = "Joe Bar",
title = "A Scientific Article 3",
year = "1995"
}
@Book{p4,
author = "Jane Baz",
title = "A Scientific Article 4",
year = "2005"
}
@Book{p5,
author = "A. U. Thor and John Doe",
title = "A Scientific Article 5",
year = "2010"
}
@Book{p6,
author = "Jane Baz",
title = "A Scientific Article 6",
year = "2015"
}
\end{filecontents}
\addbibresource{\jobname.bib}
\nocite{*}
\begin{document}
In: \parencite{p4, p1, p2, p3, p5, p6}, ``Thor and Doe 1975, 2010'' and ``Doe
1985'' should be \emph{emphasized} (but the corresponding entries in the
References section should remain typeset as the others).
\printbibliography
\end{document}
注意:我问过类似的问题这里但提出的解决方案不适用于标准样式authoryear
或authoryear-comp
。
答案1
如果希望这适用于多种风格,我们可以修改cite
bibmacro 如下
\DeclareFieldFormat{keywordcite}{\ifkeyword{doe}{\mkbibemph{#1}}{#1}}
\csletcs{old:cite}{abx@macro@cite}
\renewbibmacro{cite}{\printtext[keywordcite]{\csuse{old:cite}}}
平均能量损失
\documentclass{article}
\usepackage{filecontents}
\usepackage[backend=biber,style = authoryear-comp]{biblatex}
\usepackage[colorlinks=true, breaklinks, allcolors = blue]{hyperref}
\DeclareSourcemap{%
\maps[datatype=bibtex]{%
\map{%
\step[fieldsource=author, match=Doe, final]%
\step[fieldset=keywords, fieldvalue=doe]%
}%
}%
}
\begin{filecontents}{\jobname.bib}
@Book{p1,
author = "A. U. Thor and John Doe",
title = "A Scientific Article 1",
year = "1975"
}
@Book{p2,
author = "John Doe",
title = "A Scientific Article 2",
year = "1985"
}
@Book{p3,
author = "Joe Bar",
title = "A Scientific Article 3",
year = "1995"
}
@Book{p4,
author = "Jane Baz",
title = "A Scientific Article 4",
year = "2005"
}
@Book{p5,
author = "A. U. Thor and John Doe",
title = "A Scientific Article 5",
year = "2010"
}
@Book{p6,
author = "Jane Baz",
title = "A Scientific Article 6",
year = "2015"
}
\end{filecontents}
\addbibresource{\jobname.bib}
\DeclareFieldFormat{keywordcite}{\ifkeyword{doe}{\mkbibemph{#1}}{#1}}
\csletcs{old:cite}{abx@macro@cite}
\renewbibmacro{cite}{\printtext[keywordcite]{\csuse{old:cite}}}
\nocite{*}
\begin{document}
In: \parencite{p4, p1, p2, p3, p5, p6}, ``Thor and Doe 1975, 2010'' and ``Doe
1985'' should be \emph{emphasized} (but the corresponding entries in the
References section should remain typeset as the others).
\printbibliography
\end{document}