Sunday, January 16, 2011

Knuth quote II

Okay, this one isn't a comment in code, yet it amuses me anyway. This is Exercise 24.1 in The TeXbook.
Can you think of a reason why you might want ‘A12’ to be a ‹hex digit› even though the letter A has category 11? (Don't worry if your answer is “no.”)
For the record, my answer was “yes.” Unfortunately, my reason wasn't correct.

3 comments:

  1. The answer is (paraphrasing, of course) that if you use \meaning\cs where \cs is a control sequence defined by \chardef or \mathchardef, then TeX outputs the value in hex and like all other uses of \meaning, the nonspace characters have catcode 12.

    For example \meaning\@cclv expands to \char"FF.

    ReplyDelete
  2. My answer was also yes but mine was the correct reason given in the Appendix A.

    ReplyDelete