Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've noticed that \catcode is poorly documented in the TeXbook. The primitive is defined as \catcode but every time it is used, it is used as \catcode` ... the backquote is never discussed. ` itself is not active (right?) so I don't understand its function. Is it required for \catcode to work properly?

share|improve this question

1 Answer 1

up vote 44 down vote accepted

The backquote notation is discussed in the TeXbook, page 44.

\catcode takes as its first argument the character code of the character you want to change the catcode of. For example,

\catcode65=\active

will make ‘A’ an active character.

Instead of inserting the number ‘65’ directly, TeX allows the character code of a character to be inserted with the backtick notation you're referring to:

\catcode`A=\active

You need to escape the character if it happens to have a special catcode, though: `\%, for instance.

This backtick notation can be used wherever TeX expects a number. E.g.,

\number`A

will typeset ‘65’.

share|improve this answer
4  
Beat me to it by moments, Will. Just to add, this is described in the TeXbook, page 44. –  Lev Bishop Sep 21 '10 at 1:59
    
Feel free to fix up any of my clunky statements. My explaining-brain feels like mush today. –  Will Robertson Sep 21 '10 at 2:23
    
I guess it should read \catcode'A=\active in your example (of course with a backtick; don't know how to put a backtick into the middle of a code sample.) –  Hendrik Vogt Sep 21 '10 at 7:45
    
Oh yes, that was quoted incorrectly. Thanks for spotting the error. –  Will Robertson Sep 21 '10 at 11:30
    
Thanks for that informative explanation. To recap: in situations where TeX is looking for a number, it will interpret ` as "the character code of the next character". You have to admit, sometimes it's hard to navigate the TeXbook! –  Brandon Kuczenski Sep 21 '10 at 21:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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