2

I need to xdef some data. In rare cases it'll contain cedilles like:

\xdef\xxx{spam\c{e}eggs}
\bye

Unfortunately this failes. Is there a chance to get this working?

(I'm on LaTeX in my code, using etoolbox, but to my understanding the above plain tex example is identical. And minimal.)

3
  • 1
    Use \makeatletter \protected@xdef\x{spam\c{e}eggs} \makeatother ...
    – Werner
    Feb 29, 2016 at 23:53
  • 1
    in latex you should never use \xdef on general text use \protected@xdef and the \c will be kept safe. Feb 29, 2016 at 23:53
  • 1
    It is good to chose a minimal example but here your example is actually a rather different case. the definitions of \c in plain tex and latex are completely different. \c in plain is a simple macro that always places a cedilla under its argument using an align construct. in latex it is a font encoding specific command that may use an alignment or a pre-built glyph from the font for encodings that include such characters. Feb 29, 2016 at 23:56

1 Answer 1

7

In plain TeX you could use

\xdef\xxx{spam\noexpand\c{e}eggs}
\bye

In LaTex you could also do that but far better would be to use

\protected@xdef\xxx{spam\c{e}eggs}

assuming @ is a letter at that point (in a package file).

Note, the definitions of \c in plain tex and latex are completely different. \c in plain is a simple macro that always places a cedilla under its argument using an align construct. in latex it is a font encoding specific command that may use an alignment or a pre-built glyph from the font for encodings that include such characters.

1
  • This was very helpful. While I'm using etoolbox on LaTeX in the end, I needed to add protect@ to csxdef and eappto and got it working. Great, thanks a lot!
    – wobsta
    Mar 1, 2016 at 0:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .