1

In the context of what is essentially publication list, I call the following macro:

\newcommand{\makeauthorbold}[1]{%
  \DeclareNameFormat{author}{%
    \ifthenelse{\value{listcount}=1}
    {%
      {\expandafter\ifstrequal\expandafter{\namepartfamily}{#1}{\mkbibbold{\namepartfamily\addcomma\addspace \namepartgiveni}}{\namepartfamily\addcomma\addspace \namepartgiveni}}
      %
    }{\ifnumless{\value{listcount}}{\value{liststop}}
        {\expandafter\ifstrequal\expandafter{\namepartfamily}{#1}{\mkbibbold{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni}}{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni}}
        {\expandafter\ifstrequal\expandafter{\namepartfamily}{#1}{\mkbibbold{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni\addcomma\isdot}}{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni\addcomma\isdot}}%
      }
    \ifthenelse{\value{listcount}<\value{liststop}}
    {\addcomma\space}
  }
}

which is stored externally in a .tex, referenced in the preamble via \input{<file name>}, and called in the document body by:

\makeauthorbold{<author last name>}

In the publication list, which is actually multiple publication list (imagine one for every member of a working group) the bibliogrpahy is printed in the following way

% point to member a publication list
\newcommand\bibnamea{.../member_a.bib}
% add bib resource and define section title / heading
\addbibresource{\bibnamea}%
\def\sectiona{Member a publications}%

% print publication list for member a
\begin{numberedpublist}{\sectiona}{\bibnamea}{keyword={<keyword(s) to help filter>}}%
\end{numberedpublist}%

where the numberedpublist environment is defined as follows

% define an environment for a numbered publication list
\newenvironment{numberedpublist}[3]
{%
\section*{#1}%
\begin{refsection}[#2]%
\nocite{*}%
\printbibliography[heading=none,env=bibenvnumberedpublist,#3]%
\end{refsection}%
}%
{}%

which also has a corresponding bibenvironment definition given the name `bibenvnumberedpublist' (omitting for sake of simplicity).

One ends up with an environment with 3 arguments: the bib resource, the heading, and any keywords you want the bib items to possess in order for them to be qualified for display. By using the \nocite*{}, one does not have to deal with any bibtexkeys; all entries possessing the right keywords are printed.

The issue is that for some reason, the \makeauthorbold{} call leads to an error such as:

\begin{refsection} on input line 999 ended by \end{numberedpublist}

When I don't use \makeauthorbold{}, no issue. My guesses are the following:

  1. The \makeauthorbold{} could stand to be made more robust.

  2. The way I'm mixing the numberedpublist environment definition, \refsection and possibly \section is wacky.

moewe
  • 175,683
  • 2
    Why is there no MWE? – siracusa Jul 15 '19 at 00:51
  • 1
    Please include a full example document showing the code snippets in action (an MWE) in future questions of a similar kind. I had to spend quite some time piecing together the code and the information in the question to get something working and even then I had to modify bits of the code (because bibenvnumberedpublist wasn't defined). An MWE makes it much easier for people to get started helping you. An MWE is also the best tool to make sure that we are all talking about the same thing. – moewe Jul 15 '19 at 05:12
  • 1
    As a small aside: At least with the definition shown in the question it seems a bit odd that numberedpublist would be an environment. The same should be doable with a normal macro. – moewe Jul 15 '19 at 05:16

1 Answers1

4

The issue is easier to see (for me anyway) when we indent the definition of \makeauthorbold a bit.

\newcommand{\makeauthorbold}[1]{%
  \DeclareNameFormat{author}{%
    \ifthenelse{\value{listcount}=1}
      {{\expandafter\ifstrequal\expandafter{\namepartfamily}{#1}
         {\mkbibbold{\namepartfamily\addcomma\addspace \namepartgiveni}}
         {\namepartfamily\addcomma\addspace \namepartgiveni}}}
      {\ifnumless{\value{listcount}}{\value{liststop}}
         {\expandafter\ifstrequal\expandafter{\namepartfamily}{#1}
           {\mkbibbold{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni}}
           {\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni}}
         {\expandafter\ifstrequal\expandafter{\namepartfamily}{#1}
            {\mkbibbold{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni\addcomma\isdot}}
            {\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni\addcomma\isdot}}}%
    \ifthenelse{\value{listcount}<\value{liststop}}
      {\addcomma\space}
  }
}

Looking at the last \ifthenelse, the reader will notice that it is missing the <false> branch. The code only contains

\ifthenelse{<condition>}
  {<true>}

while the correct syntax would be

\ifthenelse{<condition>}
  {<true>}
  {<false>}

The missing <false> argument will cause an error at some point, when LaTeX tries to grab it and grabs something else that 'looks' like the missing argument instead. This can set off a chain reaction. A structurally very similar issue was discusses at the biblatex bugtracker a while ago: https://github.com/plk/biblatex/issues/874. Changes to some internals mean that this error can have more serious consequences in more recent versions of biblatex than they used to.

The syntactically corrected version would read

\newcommand{\makeauthorbold}[1]{%
  \DeclareNameFormat{author}{%
    \ifthenelse{\value{listcount}=1}
      {{\expandafter\ifstrequal\expandafter{\namepartfamily}{#1}
         {\mkbibbold{\namepartfamily\addcomma\addspace \namepartgiveni}}
         {\namepartfamily\addcomma\addspace \namepartgiveni}}}
      {\ifnumless{\value{listcount}}{\value{liststop}}
         {\expandafter\ifstrequal\expandafter{\namepartfamily}{#1}
           {\mkbibbold{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni}}
           {\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni}}
         {\expandafter\ifstrequal\expandafter{\namepartfamily}{#1}
            {\mkbibbold{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni\addcomma\isdot}}
            {\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni\addcomma\isdot}}}%
    \ifthenelse{\value{listcount}<\value{liststop}}
      {\addcomma\space}
      {}%
  }
}

On closer inspection of the output, it turns out that this version has some inconsistencies when it comes to the comma after the last name in the list (if there is more than one author, there is a comma after the name).

The code also completely bypasses any of the normal name formatting routines used by biblatex and seems to print far too many commas.

You can find some more elegant alternatives for bold names at Make specific author bold using biblatex (don't just take the very first answer, shop around a bit and see what alternatives there are).

moewe
  • 175,683
  • Great find on the missing false branch of the \ifthenelse. Substituting your updated definition with correct syntax solved the issue. – John Chris Jul 15 '19 at 16:34