Is there some dedicated expl3 command that is equivalent to the backtick notation of TeX in order to determine the character code?

  • 3
    The backtick notation is part of the 'core' TeX idea of a 'number': we've not tried to change that (not I think possible anyway). Is there some reason you can't use just a backtick in the normal way? – Joseph Wright Aug 12 '14 at 8:26
  • @JosephWright: I just asked out of curiosity. Of course, there is nothing more compact than a single backtick, and I am happy to use it without breaking l3 conventions. Thanks! – AlexG Aug 12 '14 at 8:34

As expl3 is based on TeX primitives, ultimately it is constrained by the same rules as TeX (or at least e-TeX). In particular, the concept of a <integer denotation> which can be used inside an <integer expression> is the same in expl3 as it is anywhere else in TeX (and <integer expression> is an e-TeX concept using the \numexpr primitive). The backtick notation is part of the standard TeX syntax for an <integer denotation> and so it forms part of the expl3 syntax too, such that

\int_eval:n { `a } % => 97

is perfectly valid. Almost all integer input for expl3 takes the form of <integer expression>s, so something like

\int_eval:n { `z - ( `a - 1 ) } % => 26

is also valid.

At the moment, the documentation does not cover this sort of thing, but clearly we do need to address that.

  • It could be disabled by giving the backtick a different category code, but why would anybody want it? ;-) – egreg Aug 12 '14 at 8:49
  • @egreg \the\catcode`\`\bye produces 12. I expected 13 (active character). Thus, it is impossible to define (or \let) a (L3) command that could be equivalent to a single backtick? – AlexG Aug 12 '14 at 8:58
  • 2
    @AlexG The usual category code of the backtick is indeed 12; Plain TeX and LaTeX have \lq that is defined by \def\lq{`} so that \lq can be used in contexts of numbers: \the\catcode\lq a returns 11. – egreg Aug 12 '14 at 9:01
  • @Joseph : Is \int_eval:n{ `a } to be preferred over \number`a ? – AlexG Aug 12 '14 at 11:15
  • @AlexG In expl3 code certainly yes: we don't have a direct interface for the 'raw' \number: \int_eval:n is equivalent to \number\numexpr#1\relax. – Joseph Wright Aug 12 '14 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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