Here's a example with the "! Improper alphabetic constant
" error:
%% this is ok
\newcount\mychar
\mychar=\number`a\relax
\showthe a % shows You can't use `the letter a' after \the
\showthe\mychar % shows 97
%% this is not ok
\let\Char=a
\showthe\Char % shows You can't use `the letter a' after \the
\mychar=\number`\Char\relax % here error comes
\showthe\mychar
Setting the counter should expand till non-expandable token (in this case it's \relax
). Question: why is \Char
not expanded?
Best Answer
\Char
is not expanded because it is not an expandable token. Unlike\def\Char{a}
which expands toa
\let
defines a token that essentially isa
and likea
it does not expand.The only way to get hold of this in classic TeX is to take
\meaning\Char
which will besplit that up on spaces, and if the first two words are
the letter
take the letter which will bea
and then use the`a
syntax as you used.Look at the source of the
bm
package which does a lot of this:-)Working example (plain TeX)
which produces a log
showing the macro accepts explicit or implicit character tokens.