使用 biblatex 和 babel 包问题将特定作者设为粗体

使用 biblatex 和 babel 包问题将特定作者设为粗体

提出的解决方案是讨论使用 biblatex 将特定作者设为粗体,在使用 babel 包的“法语”语言时无法正常工作。我猜想 babel 中的法语选项会覆盖 biblatex 生成的给定名称格式。有解决方案吗?

可以使用以下代码重现此问题。我使用的是 biblatex (v3.10) 和 babel (v3.17) 的最新更新版本。

有没有办法扩展此代码,以便在同一个参考文献中以粗体突出显示某些作者的姓名,并以下划线字体突出显示其他作者的姓名?

% !TeX TXS-program:bibliography = txs:///biber
\documentclass{article}

%\usepackage[french]{babel}

\usepackage{xpatch}
\usepackage[backend=biber,maxbibnames=99,defernumbers=true,sorting=ydnt,giveninits=true]{biblatex}


\begin{filecontents}{\jobname.bib}
    @InProceedings{identifier1,
        Title                    = {Some Awesome Title},
        Author                   = {Some Author and Another Author},
        AUTHOR+an                = {1=gras},
        Booktitle                = {Some Book about the Future},
        Year                     = {2042},
        Pages                    = {1--42}
    }

    @InProceedings{identifier2,
        Title                    = {Some So-So Title},
        Author                   = {First Author and Second Author},
        Booktitle                = {An okay Booktitle},
        Year                     = {2000},
        Pages                    = {1--100}
    }
\end{filecontents}
\addbibresource{\jobname.bib}


%% Other alternative which don't work.
%\renewcommand*{\mkbibnamegiven}[1]{%
%    \ifitemannotation{gras}
%    {\textbf{#1}}
%    {#1}}
%
%\renewcommand*{\mkbibnamefamily}[1]{%
%    \ifitemannotation{gras}
%    {\textbf{#1}}
%    {#1}}


\def\makenamesetup{%
    \def\bibnamedelima{~}%
    \def\bibnamedelimb{ }%
    \def\bibnamedelimc{ }%
    \def\bibnamedelimd{ }%
    \def\bibnamedelimi{ }%
    \def\bibinitperiod{.}%
    \def\bibinitdelim{~}%
    \def\bibinithyphendelim{.-}}    
\newcommand*{\makename}[2]{\begingroup\makenamesetup\xdef#1{#2}\endgroup}

\newcommand*{\boldname}[3]{%
    \def\lastname{#1}%
    \def\firstname{#2}%
    \def\firstinit{#3}}
\boldname{}{}{}

% Patch new definitions
\renewcommand{\mkbibnamegiven}[1]{%
    \makename{\currname}{#1}%
    \makename{\findname}{\firstname}%
    \makename{\findinit}{\firstinit}%
    \ifboolexpr{ test {\ifdefequal{\currname}{\findname}}%
        or test {\ifdefequal{\currname}{\findinit}} }%
    {\mkbibbold{#1}}{#1}%
}

\renewcommand{\mkbibnamefamily}[1]{%
    \makename{\currname}{#1}%
    \makename{\findname}{\lastname}%
    \ifboolexpr{ test {\ifdefequal{\currname}{\findname}} }%
    {\mkbibbold{#1}}{#1}%
}

\boldname{Author}{Some}{S.}

\begin{document}
    Examples :
    \nocite{*}
    \printbibliography

\end{document}

答案1

注释功能的一般方法如下PLK 的答案:使用 biblatex 将特定作者设为粗体作品。

如果您使用french,则宏\mkbibnamefamily会自动更改,以便以小写字母打印作者姓名。这意味着您对 的重新定义\mkbibfamily将被覆盖。您可以使用

\DefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily}

在全

\documentclass{article}
\usepackage{libertine}
\usepackage[french]{babel}

\usepackage[backend=biber,maxbibnames=99,defernumbers=true,sorting=ydnt,giveninits=true]{biblatex}

\begin{filecontents}{\jobname.bib}
@InProceedings{identifier1,
  Title                    = {Some Awesome Title},
  Author                   = {Some Author and Another Author},
  AUTHOR+an                = {1=gras},
  Booktitle                = {Some Book about the Future},
  Year                     = {2042},
  Pages                    = {1--42}
}

@InProceedings{identifier2,
  Title                    = {Some So-So Title},
  Author                   = {First Author and Second Author},
  Booktitle                = {An okay Booktitle},
  Year                     = {2000},
  Pages                    = {1--100}
}
\end{filecontents}
\addbibresource{\jobname.bib}



\renewcommand*{\mkbibnamegiven}[1]{%
  \ifitemannotation{gras}
    {\mkbibbold{#1}}
    {#1}}

\renewcommand*{\mkbibnamefamily}[1]{%
  \ifitemannotation{gras}
    {\mkbibbold{#1}}
    {#1}}

\DefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily}

\begin{document}
 \nocite{*}
  \printbibliography
\end{document}

在此处输入图片描述

如果你想要使用小写字母的作者,你需要

\renewcommand*{\mkbibnamefamily}[1]{%
  \ifitemannotation{gras}
    {\mkbibbold{\textsc{\textnohyphenation{#1}}}}
    {\textsc{\textnohyphenation{#1}}}}

但是您需要一种支持粗体小型大写字母的字体(拉丁现代字体不支持)。

在此处输入图片描述

相关内容