As intentioned in the title I want a macro \skipfirstletters in plain-TeX, that skips the first letters (catcode 11) from the \jobname. For instance if the TeX-file is named Test0xy.tex it should expand to just 0xy.

I tried the following lines as Test0xy.tex:

\def\skipfirstletters#1{\ifcat A#1\expandafter\skipfirstletters\else#1\fi}
\skipfirstletters Test0xy\par


The result is just
0xy Test0xy Test0xy

I don't understand alot, e.g. why the expanded \jobname in Line 4 (is it expanded before \skipfirstletters?) does not behave like the plain tokens in Line 2.

I want to use the expanded macro as argument for others if this matters.

Thanks a lot to the community and sorry for my poor knowledge of TeX.

  • 1
    the tokens in jobname are all catcode 12 or 10 Apr 10 '18 at 9:07
  • 12 ok, but why 10? i thought catcode 10 means "spaces"... Apr 10 '18 at 9:10
  • If a space character somehow creeps in \jobname, its category code will be 10.
    – egreg
    Apr 10 '18 at 9:12
  • 1
    All characters in \jobname have catcode 12 (other) to avoid trouble with special characters like \ or % in it. The only exception is the space. I guess this is because file name strings once saved internally do not have catcodes anymore, as there are not material to be typeset but to be used internally. If you reinsert them into the typeset content a neutral catcode is selected to be on the save side, I guess. The TeXBook surely states the reason. Apr 10 '18 at 9:29

the tokens in \jobname are like \string and have catcode 12 (or 10 if it is a space), however you can still test the catcode settings for the slots to test whether it is a letter or not:

\ifnum11=\catcode`#1 \expandafter\skipfirstletters\else#1\fi}
\skipfirstletters Test0xy\par


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.