?SPAM? - [texhax] choice of documentstyle upon \jobname
Philip TAYLOR
P.Taylor at Rhul.Ac.Uk
Thu Dec 1 00:13:11 CET 2005
This one is quite nasty ...
Susan Dittmar wrote:
> Hi all,
>
> I would like to choose the documentclass (in fact, only some of the
> documentclass options) according to \jobname. I tried something like
>
> \ifx\jobname{first}
> \documentclass[first]{...}
> \else
> \documentclass[second]{...}
> \fi
>
> (and some variations thereof), but somehow it never uses the first
> set of options even when \typeout{\jobname} yields 'first'.
> Where's my mistake?
Lots of mistakes, but don't worry about them, the problem
is distinctly non-trivial. See Victor Eijkhout's magnificent
/TeX by Topic/ for the gory details :
http://www.eijkhout.net/tbt/
but in the meantime here's the guts of a solution
(just replace "True" and "False" by whatever you
want to happen). Note that the target filename
for this example is "DocClass.tex" : you'll need
to change the embedded string if you want to test
for a different name, or add more strings if you
want to test for multiple possibilities.
Philip Taylor
--------
\def \0%
{\begingroup
\def \1{\gdef \thisname}
\count 0 = 0
\loop
\catcode \count 0 = 12
\ifnum \count 0 < 255
\advance \count 0 by 1
\repeat
\catcode `\\ = 0
\catcode `\{ = 1
\catcode `\} = 2
}
\def \2%
{\endgroup}
\0\1{DocClass}\2
\edef \ThisName {\thisname}
\edef \JobName {\jobname}
\ifx \ThisName \JobName
True
\else
False
\fi
\end
More information about the texhax
mailing list