[texhax] choice of documentstyle upon \jobname

Reinhard Kotucha reinhard.kotucha at web.de
Thu Dec 1 02:34:44 CET 2005


>>>>> "Susan" == Susan Dittmar <S.Dittmar at eureca.de> writes:

  > 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

It is more difficult than necessary to do it this way.  If you follow
Phil's advice and try to understand how TeX works internally, you'll
see that there are some quite nasty things.  An "f" is not just an "f"
in TeX.  Look for "\catcode" in TeX by Topics.

The "f" in "first" you typed has \catcode 11 while the "f" returned by
\jobname has \catcode 12.


A very simple solution is this:

Remove the \documentclass stuff completely from the file.  Assume this
file is called paper.tex.

Then prepare other files:

paper-first.tex:
_________________________________
\documentclass[first]{...}
\input{paper}
_________________________________

paper-second.tex:
_________________________________
\documentclass[second]{...}
\input{paper}
_________________________________

paper-printversion.tex:
_________________________________
\documentclass[third]{...}
\usepackage[monochrome]{color}
\input{paper}
_________________________________

The main advantage of this approach is that it is easy to understand,
even in a few years.  And it's clean LaTeX.

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