我的目标是使用 BiBLaTeX 和 numeric-comp 样式以及 family-given/given-family 方式对作者姓名进行排序,所有姓名均以粗体显示。这是我的 MWE:
\documentclass{scrreprt}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[
backend=biber,
style=numeric-comp,
sorting=none,
]{biblatex}
\addbibresource{test.bib}
\DeclareNameAlias{sortname}{family-given/given-family-bold}
\DeclareNameFormat{family-given/given-family-bold}{\mkbibbold{%
\ifnumequal{\value{listcount}}{1}
{\ifgiveninits
{\usebibmacro{name:family-given}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}
{\usebibmacro{name:family-given}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}%
\ifboolexpe{%
test {\ifdefvoid\namepartgiven}
and
test {\ifdefvoid\namepartprefix}}
{}
{\usebibmacro{name:revsdelim}}}
{\ifgiveninits
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}}%
\usebibmacro{name:andothers}}}
\DeclareNameAlias{sortname}{given-family-bold}
\DeclareNameAlias{author}{given-family-bold}
\DeclareNameAlias{editor}{given-family-bold}
\DeclareNameAlias{translator}{given-family-bold}
\usepackage{filecontents}
\begin{filecontents}{test.bib}
@book{Doe86,
author = {Doe, John},
year = {1986},
title = {some book},
}
\end{filecontents}
\begin{document}
I'm citing \cite{Doe86}
\printbibliography
\end{document}
奇怪的是,无论我编译多少次(latex 和 biber),它都会产生以下输出。我做错了什么?
答案1
对于当前版本,biblatex
我会使用名称包装器将粗体应用于名称。如果您想要混合顺序family-given/given-family
,您仍然需要重新定义名称格式(因为数字样式的默认顺序是given-family
顺序)。
\documentclass{scrreprt}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[
backend=biber,
style=numeric-comp,
sorting=none,
]{biblatex}
\DeclareNameAlias{sortname}{family-given/given-family}
\DeclareNameAlias{author}{sortname}
\DeclareNameAlias{editor}{sortname}
\DeclareNameAlias{translator}{sortname}
\DeclareNameWrapperFormat{sortname}{\mkbibbold{#1}}
\DeclareNameWrapperAlias{author}{sortname}
\DeclareNameWrapperAlias{editor}{sortname}
\DeclareNameWrapperAlias{translator}{sortname}
\addbibresource{biblatex-examples.bib}
\begin{document}
I'm citing \cite{sigfridsson,nussbaum}
\printbibliography
\end{document}
问题出在代码中,它定义了一种名称格式(family-given/given-family-bold
),但是用过的一种不同的、不存在的格式(given-family-bold
)。不存在的格式会导致您得到奇怪的输出。可以按如下方式重新编写(但我还是更喜欢上面的解决方案)。
\documentclass{scrreprt}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[
backend=biber,
style=numeric-comp,
sorting=none,
]{biblatex}
\DeclareNameFormat{family-given/given-family-bold}{%
\mkbibbold{%
\ifnumequal{\value{listcount}}{1}
{\ifgiveninits
{\usebibmacro{name:family-given}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}
{\usebibmacro{name:family-given}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}%
\ifboolexpe{%
test {\ifdefvoid\namepartgiven}
and
test {\ifdefvoid\namepartprefix}}
{}
{\usebibmacro{name:revsdelim}}}
{\ifgiveninits
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}}%
\usebibmacro{name:andothers}}}
\DeclareNameAlias{sortname}{family-given/given-family-bold}
\DeclareNameAlias{author}{sortname}
\DeclareNameAlias{editor}{sortname}
\DeclareNameAlias{translator}{sortname}
\addbibresource{biblatex-examples.bib}
\begin{document}
I'm citing \cite{sigfridsson,nussbaum}
\printbibliography
\end{document}
输出是一样的。