Hans Hagen wrote:
BILLET Olivier wrote:
By the way, does this include the possibility to treat the character in different ways depending on the current mode (math/text)? Because, in the current setting, if you request for 3cm before `:' and then define a mathematical function $f : R \to Z$ you'll end up with a huuuge space between f and : which you certainly isn't what you want.
see attached file; taco may know other tricks (i remember that there is some mechanism in tex for active char treatment in math mode)
It is possible to treat an arbitrary character as if it was \active inside math mode, but not the other way around: when a character has catcode \active, it is always treated as that macro, regardless of the current mode. For curious people, here is how you make a "mathmode only" macro: \mathcode`\!="8000 \begingroup \catcode`\!=13 \gdef!{\it math} \endgroup This is a $!$ test!. Cheers, Taco