0

I'm trying to bold my name in a publication list. After an embarrassing amount of time/experimentation I have something I'm happy with via etoolbox and xstring:

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

However, this results in an odd indentation artefact when I do printbibliography twice: enter image description here

Am I doing something incorrect with the macro or is this an actual bug? Thanks! 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}

daknowles
  • 103
  • 2

1 Answers1

1

The round brackets aren't properly matched inside the \ifboolexpr. Unfortunately, etoolbox does not warn about it, it just messes up the surrounding typesetting.

The following MWE (without any round brackets - they were not required here) works as intended

\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}

Properly aligned entries in bibliography

moewe
  • 175,683
  • Note that there are other ways to bold certain authors that don't rely on xstring. (xstring can be a bit tricky at times.) See https://tex.stackexchange.com/q/73136/35864. – moewe Oct 30 '23 at 05:58
  • Thank you so much. I started with those options but couldn't get anything I was happy with for bolding multiple authors. – daknowles Oct 31 '23 at 16:11