?SPAM? - Re: [texhax] choice of documentstyle upon \jobname

Reinhard Kotucha reinhard.kotucha at web.de
Fri Dec 2 00:21:10 CET 2005


>>>>> "Philip" == Philip TAYLOR <P.Taylor at rhul.ac.uk> writes:

  > There's even an approach which /does/ allow \jobname to be used
  > without the need to get into catcodes and the difference between
  > an expandable token (\jobname) and a macro (\thisname).

  > Let the projects live in a directory "P".  Create sub-directories
  > of "P" called <whatever>, one for each possible value of \jobname.
  > Create one-line include files, one in each sub-directory, called
  > (e.g.,) "DocClass.tex".  Each should contain a single line of the
  > form

  > 	\documentclass [<options>]{<class>}

  > where <options> and <class> are as required for that specific
  > value of \jobname.

  > Each main file in "P" will then start with the line

  > 	\input \jobname/DocClass

  > and each will therefore \input as the very first record

  > 	\documentclass [<options>]{<class>}

  > where both <options> and <class> are a function of the jobname.

  > Clear as mud ?! :-)

The idea obviously is to expand \jobname in an environment which is
not aware of catcodes.  The environment is the shell in this case.
BTW, Susan had been very close to this approach when she realized that
\typeout{\jobname} works.

There is an interesting way to use \jobname inside tex with catcodes
ignored.  The idea is from Hartmut Henkel:

  \expandafter\def\csname first\endcsname{\documentclass[abc]{...}}
  \expandafter\def\csname second\endcsname{\documentclass[xyz]{...}}

  \csname\jobname\endcsname

Isn't it nice?  It's very close to Susan's first approach but
circumvents a lot of problems.

This will work in LaTeX:

testnamedef.tex:
_______________________________________________________
  \makeatletter % allow `@' in macro names
    \@namedef{first}{\typeout{***first***}}
    \@namedef{second}{\typeout{***second***}}
    \@nameuse{\jobname}
  \makeatother % disallow `@' in macro names
  \stop
_______________________________________________________

ln -s testnamedef.tex first.tex
ln -s testnamedef.tex second.tex
latex first.tex
latex second.tex


Regards,
  Reinhard

-- 
----------------------------------------------------------------------------
Reinhard Kotucha			              Phone: +49-511-4592165
Marschnerstr. 25
D-30167 Hannover	                      mailto:reinhard.kotucha at web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------




More information about the texhax mailing list