我正在尝试在出版物列表中加粗我的名字。经过一段令人尴尬的时间/实验后,我通过以下方式获得了一些让我满意的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}