79809571

Date: 2025-11-05 02:38:07
Score: 1
Natty:
Report link

(Couldn't comment on your answer despite having enough reputation, so leaving another answer instead)

Your question about \gdef versus \xdef is addressed by https://tex.stackexchange.com/a/353139, which explains that:

With [\def<cs>{<replacement text>}] you define <cs> to look for its arguments (if any) and to be replaced by <replacement text>, which is not interpreted in any way at definition time. With [\edef] the replacement text is fully expanded at definition time.

That same distinction applies to \gdef and \xdef, respectively. They function just like \def and \edef except that their definitions are global (persisting after the end of the block in which they were executed).

So, yes, switching from \xdef to \gdef just prevents the immediate expansion of the replacement text.

Reasons:
  • RegEx Blacklisted phrase (1.5): enough reputation
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: LRitzdorf