参考书目中的粗体作者

参考书目中的粗体作者

我想制作一个自定义书目,并且几乎所有东西都可以正常工作。我唯一需要的是粗体、大写字母的作者。实际上,我使用在 stackexchange 上找到的示例让它工作,但其中有一个错误,只有在只有一位作者时才会出现。

它们应该以粗体大写形式打印。如下图所示,情况已经如此。但在第一个参考文献中,作者的名字打印错误。应该是“RAUCH, G.”而不是“GG RAUCH”。不知道为什么,但名字的首字母打印了两次。

\documentclass{article}

\usepackage[
    backend=biber,
    style=authoryear-icomp,
    sorting=nyt,
    maxbibnames=3,
    giveninits=true,
    dashed=false,
]{biblatex}

\usepackage{xpatch}

%\DeclareNameFormat{author}{\MakeUppercase{#1}}

\def\bmkbibbold#1\emkbibbold{\mkbibbold{#1}}
\xpretobibmacro{author}{\bmkbibbold}{}{}
\xpatchbibmacro{author}
{\usebibmacro{date+extradate}}
{\emkbibbold\usebibmacro{date+extradate}}
{}{}

\xpretobibmacro{bbx:editor}{\bmkbibbold}{}{}
\xpatchbibmacro{bbx:editor}
{\usebibmacro{date+extradate}}
{\emkbibbold\usebibmacro{date+extradate}}
{}{}

\xpretobibmacro{bbx:translator}{\bmkbibbold}{}{}
\xpatchbibmacro{bbx:translator}
{\usebibmacro{date+extradate}}
{\emkbibbold\usebibmacro{date+extradate}}
{}{}



\DeclareNameAlias{sortname}{given-family-upper}

\DeclareNameFormat{given-family-upper}{%
    \ifgiveninits
    {\usebibmacro{name:given-family}
        {\MakeUppercase{\namepartfamily}}
        {\MakeUppercase{\namepartgiveni}}
        {\MakeUppercase{\namepartprefix}}
        {\MakeUppercase{\namepartsuffix}}}
    {\usebibmacro{name:given-family}
        {\MakeUppercase{\namepartfamily}}
        {\MakeUppercase{\namepartgiveni}}
        {\MakeUppercase{\namepartprefix}}
        {\MakeUppercase{\namepartsuffix}}}%
    \usebibmacro{name:andothers}}


\begin{filecontents}{test2.bib}
@inproceedings{seabold2010,
    title={statsmodels: Econometric and statistical modeling with python},
    author={{Seabold, S.} and {Perktold, J.}},
    booktitle={9th Python in Science Conference},
    year={2010},
}
@online{rauch2022,
    author = {Rauch, G},
    title = {Was ist ein Software-Entwurf?},
    date = {2022},
    url = {https://www.dev-insider.de/was-ist-ein-software-entwurf-a-1088943/},
    urldate = {2022-03-29}
}
\end{filecontents}

\addbibresource{test2.bib}

\begin{document}

\cite{seabold2010} \\
\cite{rauch2022}

\printbibliography

\end{document}

在此处输入图片描述

知道这里的问题是什么吗?

答案1

现在有更多优雅的方式来获得粗体作者姓名\DeclareNameWrapperFormatbiblatex 在参考书目中打印“family=, familyi=”等), 我建议您使用它,而不是使用修补多个 bibmacros 的繁琐解决方案。

您也不应该用花括号强制使用特定的名称格式。而是使用 选择所需的名称格式\DeclareNameAlias

\documentclass{article}

\usepackage[
  backend=biber,
  style=authoryear-icomp,
  maxbibnames=3,
  giveninits=true,
  dashed=false,
]{biblatex}

\DeclareNameAlias{sortname}{family-given}
\DeclareNameWrapperFormat{sortname}{\mkbibbold{#1}}

\begin{filecontents}{\jobname.bib}
@inproceedings{seabold2010,
  title     = {statsmodels: Econometric and statistical modeling with python},
  author    = {Seabold, S. and Perktold, J.},
  booktitle = {9th Python in Science Conference},
  year      = {2010},
}
@online{rauch2022,
  author  = {Rauch, G.},
  title   = {Was ist ein Software-Entwurf?},
  date    = {2022},
  url     = {https://www.dev-insider.de/was-ist-ein-software-entwurf-a-1088943/},
  urldate = {2022-03-29}
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\cite{seabold2010,rauch2022}

\printbibliography
\end{document}

“Rauch, G. (2022)。什么是软件设计?url:https://www.dev-insider.de/was-ist-ein-software-entwurf-a-1088943/(访问于 2022 年 3 月 29 日)。Seabold, S. 和 Perktold, J. (2010)。“statsmodels:使用 Python 进行计量经济学和统计建模”。在:第 9 届 Python 科学大会上。”名字以粗体显示

相关内容