Re: environment variable

Harald Hanche-Olsen <[email protected]>
Newsgroups gmane.comp.tex.tetex.general
Message-ID <[email protected]>
+ Oliver Grewe <[email protected]>:

|  in our documents we have often something like:
| 
|  \usepackage{$HOME/path...}
| 
|  or
| 
|  \input{$HOME/path...}

Ugh.

|  Must we stay on tetex-1.0 or is there a possibility to teach
| tetex-3.0 to know environment-variables under UNIX?

You might be able to use the \everyjob token register.
In latex.ini, after the line with \input latex.ltx:

\everyjob\expandafter{\the\everyjob ...}

where ... is a sequence of commands you wish to run for every latex
job.  To keep it simple, maybe put something like

\InputIfFileExists{everylatexrun}

and then let each user have his own everylatexrun.tex which defines
the expansion of $HOME.

The other ingredient in a fix would be to add magic to actually
perform the expansion.  Let me take a stab at it (NB UNTESTED):

\def\HOME{/usr/home/username}% or whatever

\let\ORIGusepackage\usepackage
\renewcommand*{\usepackage}[1][]%
  {\def\do{\egroup\ORIGusepackage[#1]{\1}}%
   \bgroup\catcode`\$=0
   \afterassignment\do
   \xdef\1}

This code utilizes the fact that \usepackage expands its filename
argument.  I hope and believe the initial magic of \usepackage does
not use \1, otherwise you need to pick another name.

Redefining \input seems a bit harder, since \input in LaTeX does a lot
of magic to support both the LaTeX syntax and the plain TeX syntax at
the same time.  Looking in latex.ltx, I think you will need to do
\@iinput, which is just like \usepackage but easier, because it
doesn't use an optional argument, and \@@input, which is just the
plain TeX primitive renamed.  If you can count on your users not using
the latter, you can forget it.  Otherwise, you adapt the following,
replacing \input by \@@input.

Here is a similar, much easier, fix for plain TeX (and this is tested):

\let\ORIGinput\input
\def\input{\bgroup\catcode`\@=0\expandafter\egroup\ORIGinput}

Again, \everyjob is your hook.  Except plain TeX doesn't have
\InputIfFileExists, so you need to roll your own.

You need to rebuild formats after changing the .ini files, of course.
Don't change them in texmf-dist.  Put copies in your texmf or
texmf-local tree and edit them instead.

Sorry if this got a bit jumbled, I was typing and thinking at the same
time.

- Harald
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.