I don't understand the difference between \edef and \xdef in the following code. Clearly, the \xdef does what I'm expecting but why? AFAIK, $ does not start a group.





enter image description here

  • 1
    $ does start a group – David Carlisle Sep 11 '15 at 21:54
  • 1
    Try a $\mathsurround=10pt b$ a $b$ a and you'll see that the setting of \mathsurround does not extend to the second formula. This is because $ starts a group. – egreg Sep 11 '15 at 22:06

a math list forms a group so the first \edef definition is discarded and \meaning shows the original definition.

The definition with \xdef is the same, but is visible outside the group closed by the trailing $.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.