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} 
4
  • What's the reason for \ExplSyntaxOn? Commented Aug 13, 2020 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. Commented Aug 13, 2020 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. Commented Aug 13, 2020 at 11:49
  • @TakingItCasual An example of what you need would be useful (in a new question). Commented Aug 13, 2020 at 12:51

1 Answer 1

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.