1

Using \ExplSyntaxOn breaks \xpatchbibmacro. Can this be fixed, or will I just need to use xpatch commands elsewhere?

MWE:

\documentclass{article}

\usepackage{expl3} \usepackage{xpatch} \usepackage[style=authoryear]{biblatex}

\begin{filecontents}[overwrite]{\jobname.bib} @book{1person, author = {John Smith}, title = {Some Random Thing}, date = {1970} } @book{2people, author = {John Smith and Bob Smith}, title = {Some Other Thing}, date = {1971} } \end{filecontents} \addbibresource{\jobname.bib} \nocite{*}

\DeclareNameAlias{sortname}{given-family} \ExplSyntaxOn % Removing this fixes it... \xpatchbibmacro{date+extradate}% Remove date's parentheses, add period before (/a/428193) {\printtext[parens]}{\setunit*{\addperiod\addspace}\printtext}{}{} \ExplSyntaxOff

\begin{document} \printbibliography \end{document}

  • What's the reason for \ExplSyntaxOn? – egreg Aug 13 '20 at 11:45
  • In my document I'm using it for l3keys, and there's a lot of conditional groups. \ExplSyntaxOn can't be put into groups, which forces me to split and double my conditionals. – TakingItCasual Aug 13 '20 at 11:47
  • That's expected. Patching relies on everything having the “right” catcodes, and enabling expl3 syntax changes quite a few of them, so patching breaks. For example, if a command contains a ~ and then you patch it, it becomes a space in expl3 syntax. – Phelype Oleinik Aug 13 '20 at 11:49
  • @TakingItCasual An example of what you need would be useful (in a new question). – egreg Aug 13 '20 at 12:51

1 Answers1

3

\ExplSyntaxOn changes the category code of several characters (space, :, _, ~) and the patching routine may fail if the category codes are different from those at definition time.

Don't use \xpatch... under the scope of \ExplSyntaxOn.

egreg
  • 1,121,712