[XeTeX] dealing with \$ character

Hans Hagen pragma at wxs.nl
Thu Jul 8 09:58:40 CEST 2004

```Bruce D'Arcus wrote:

>
> On Jul 7, 2004, at 1:21 PM, Stephen Moye wrote:
>
>> Then there must be more here than meets the eye because I just
>> implemented Hans' suggestion in a small project of my own and it
>> works perfectly.
>
>
> Yeah, turns out I was looking at the wrong xsl file.  Sorry for the
> noise.
>
> What does this code actually say, just in case I need to deal with
> other characters this way?
>
> \catcode`\\$=12

catcodes are something very texy (but opinions differ on its beauty)

a character can have one of 16 catcodes and this is how tex can switch states, like

\catcode`\{=1
\catcode`\}=2

now tex sees a { as begin of a group; so, this means that you can say

\catcode`\[=1
\catcode`\]=2

as well; it also means that - by changing catcodes - you can do all kind of trickery; the downside is that when passed as argument, as in \blabla {.\$x\$..} the catcode is frozen; this is one of the reason why verbatim is always kind of tricky to handle, because verbatim environments change the catcodes

so ... \$ when it has catcode 3 will tell tex that it has run into something math; you don't want that, so by giving it catcode 12 you tell tex to see it as character

Hans

-----------------------------------------------------------------