Ampersand as namessep in biblatex label

I am trying to change the way that labels are generated. Some of it I already got working (only at maximum two authors, only last two digits of the year), but one thing does not seem to work, which is putting an ampersand between the authors if there are at least two.
In the manual on page 205 it is explained, that one can use special characters without escaping them as literals or padding, but what about the namessep field?

In the MWE I used ‘X’ in the place where an ‘&’ should be placed, but I do not know how to do it.
I suspect, that since it is converted into the .bcf file, which is XML, that the ampersand makes troubles there, so is this a bug?

Here is a MWE:

documentclass{article}
usepackage[utf8]{inputenc}
usepackage[english]{babel}
usepackage{csquotes}
usepackage{filecontents}

begin{filecontents*}{references.bib}
@article{einstein,
  author =       "Albert Einstein and Second Author",
  title =        "{Zur Elektrodynamik bewegter K{"o}rper}. ({German})
                 [{On} the electrodynamics of moving bodies]",
  journal =      "Annalen der Physik",
  volume =       "322",
  number =       "10",
  pages =        "891--921",
  year =         "1905",
  DOI =          "http://dx.doi.org/10.1002/andp.19053221004",
  keywords =     "physics"
}

@book{dirac,
  title={The Principles of Quantum Mechanics},
  author={Paul Adrien Maurice Dirac},
  isbn={9780198520115},
  series={International series of monographs on physics},
  year={1981},
  publisher={Clarendon Press},
  keywords = {physics}
}

@book{latexcompanion,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The LaTeX Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts",
    keywords  = "latex"
}
end{filecontents*}

usepackage[
backend=biber,
style=alphabetic,
citestyle=alphabetic,
maxcitenames=2,
mincitenames=2,
giveninits=true,
isbn=false,
]{biblatex}

renewcommand*{labelalphaothers}{${}^+$}

DeclareLabelalphaTemplate{
  labelelement{
    field[final]{shorthand}
    field{label}
    field[names=2, namessep={addspace{X}addspace}]{labelname}
  }
  labelelement{
    literal{addspace}
  }
  labelelement{
    field[strside=right,strwidth=2]{year}
  }
}

addbibresource{references.bib}

begin{document}
section{First section}

Items that are cited: textit{The LaTeX Companion} book cite{latexcompanion}, The Einstein's journal paper cite{einstein} and the Dirac's book cite{dirac} are physics related items. Next, a citation about textit{The LaTeX Companion} book cite{latexcompanion}.

medskip

printbibliography
end{document}

Render of MWE:
Render of MWE

Leave a Reply

Your email address will not be published. Required fields are marked *