I have a bunch of documents called wk01.tex wk02.tex and so on up to (eventually) 20. These are weekly handouts for a course I TA. Currently, each document starts with a \def\classweek{5} or whatever. I then use this in the document header. Now what I'd really like to do is have latex take the document name, do some sed-fu to strip out just the number (without its initial 0 if applicable) and then use this number in the definition of \classweek automatically. I've spotted reference to \jobname once or twice, but I'm not sure how to use that.
Is what I want to do possible?
[Are there tags appropriate for this sort of question? I couldn't think of any...]
\jobnameexpands to the file base, e.g.wk01forwk01.tex. But be careful, all non-space tokens in it have catcode 12 "other", which makes comparisons a little tricky. But for numbers this shouldn't be a problem, they have catcode 12 anyway and TeX registers don't look at the catcodes. – Martin Scharrer Feb 21 '11 at 18:52