通过 xstring+etoolbox 使用 biblatex 的 printbibliography 和作者加粗时出现不必要的偏移

通过 xstring+etoolbox 使用 biblatex 的 printbibliography 和作者加粗时出现不必要的偏移

我正在尝试在出版物列表中加粗我的名字。经过一段令人尴尬的时间/实验后,我通过以下方式获得了一些让我满意的etoolbox东西xstring

\renewcommand{\mkbibnamegiven}[1]{\ifboolexpr{(test {\IfSubStr{\namepartfamily}{Knowles}} and (test {\IfSubStr{\namepartgiven}{David}})}{\mkbibbold{#1}}{#1}}
\renewcommand{\mkbibnamefamily}[1]{\mkbibnamegiven{#1}}

printbibliography但是,当我执行两次 时,会导致出现奇怪的压痕伪影:在此处输入图片描述

是我使用宏时做错了什么吗?还是这真的是个错误?谢谢!MWE:

\documentclass[10pt, a4paper]{article}

\usepackage{filecontents}
\usepackage[backend=biber]{biblatex}
\begin{filecontents}{test.bib}
@ARTICLE{Isaev2023-ax,
  title    = "Investigating {RNA} splicing as a source of cellular diversity
              using a binomial mixture model",
  author   = "Isaev, Keren and Knowles, David A",
  journal  = "bioRxiv",
  year     =  2023,
  Keywords = {Working}
}

@ARTICLE{Brown2023-fm,
  title     = "MCFA",
  author    = "Brown†, Brielin C and Knowles†, David A and Lappalainen†, Tuuli",
  journal   = "Cell Genomics",
  year      =  2023,
      bibbase_note = {†Co-corresponding},
  Keywords = {Genetics}
}
\end{filecontents}
\addbibresource{test.bib}

\usepackage{xstring}
\usepackage{etoolbox}

\renewcommand{\mkbibnamegiven}[1]{\ifboolexpr{(test {\IfSubStr{\namepartfamily}{Knowles}} and (test {\IfSubStr{\namepartgiven}{David}})}{\mkbibbold{#1}}{#1}}
\renewcommand{\mkbibnamefamily}[1]{\mkbibnamegiven{#1}}

\begin{document}

\nocite{*}
\printbibliography[title=Journal articles, type=article, keyword=Genetics]
\noindent % doesn't help
\setlength{\parindent}{0pt}
\printbibliography[title=Working, type=article, keyword=Working]

\end{document}

答案1

圆括号内的字符没有正确匹配\ifboolexpr。不幸的是,etoolbox并没有对此发出警告,它只是弄乱了周围的排版。

以下 MWE(没有任何圆括号 - 这里不需要它们)按预期工作

\documentclass[10pt, a4paper]{article}

\usepackage[backend=biber]{biblatex}
\usepackage{xstring}

\renewcommand{\mkbibnamegiven}[1]{%
  \ifboolexpr{    test {\IfSubStr{\namepartfamily}{Knowles}}
              and test {\IfSubStr{\namepartgiven}{David}}}
    {\mkbibbold{#1}}
    {#1}}
\renewcommand{\mkbibnamefamily}[1]{\mkbibnamegiven{#1}}

\begin{filecontents}{\jobname.bib}
@ARTICLE{Isaev2023-ax,
  title    = "Investigating {RNA} splicing as a source of cellular diversity
              using a binomial mixture model",
  author   = "Isaev, Keren and Knowles, David A",
  journal  = "bioRxiv",
  year     =  2023,
  Keywords = {Working}
}
@ARTICLE{Brown2023-fm,
  title     = "MCFA",
  author    = "Brown†, Brielin C and Knowles†, David A and Lappalainen†, Tuuli",
  journal   = "Cell Genomics",
  year      =  2023,
  bibbase_note = {†Co-corresponding},
  Keywords = {Genetics}
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}
\printbibliography[title=Journal articles, type=article, keyword=Genetics]
\printbibliography[title=Working, type=article, keyword=Working]
\end{document}

参考书目中正确对齐的条目

相关内容