The following code is a subset of the answer in this question. The code provided in the answer works fine, but fails if I add a conditional \IfPackageLoaded
. I post this error as a new question, because it has not necessarily to do with the original question.
The problem has to do with the sequence \xpretobibmacro
although I have no idea why.
The failure message is below.
\documentclass{article}
\usepackage{filecontents}
\usepackage{ltxcmds}
\makeatletter
\newcommand{\IfPackageLoaded}[2]{\ltx@ifpackageloaded{#1}{#2}{}}
\makeatother
\usepackage{biblatex}
\usepackage{xpatch}
\IfPackageLoaded{biblatex}{%
% \boldnames: etoolbox-list of names to typeset bold in \printbibiliography
\newcommand*{\boldnames}{}
\newbibmacro*{name:bold}[2]{%
\def\do##1{\ifstrequal{#1, #2}{##1}{\bfseries\listbreak}{}}%
\dolistloop{\boldnames}}
\xpretobibmacro{name:last-first}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\xapptobibmacro{name:last-first}{\endgroup}{}{}
%
\DeclareNameAlias{default}{last-first/first-last}
}% \IfPackageLoaded{biblatex}
\addbibresource{publications.bib}
\begin{document}
\begin{filecontents*}{publications.bib}
@Article{Pospiech2010,
Title = {Single-sweep laser writing of 3D-waveguide devices},
Author = {Matthias Pospiech and Moritz Emons and Benjamin V\"{a}ckenstedt and Guido Palmer and Uwe Morgner},
Journal = {Opt. Express},
Year = {2010},
Number = {7},
Pages = {6994--7001},
Volume = {18},
}
\end{filecontents*}
\begin{refsection}%
\nocite{*}
\printbibliography[heading=none, sorting=ynt, resetnumbers=true] %env=numbered+bold,
\end{refsection}
\end{document}
The error is
! Undefined control sequence.
<argument> \blx@do
{Pospiech2009}\blx@listloop@i