[tex-eplain] Incorporating url.sty

Daniel H. Luecking luecking at uark.edu
Tue Aug 23 18:17:59 CEST 2005

On Tue, 23 Aug 2005 geolsoft at mail.ru wrote:

> On Tue, Aug 23, 2005 at 04:16:38PM +0200, Karl Berry wrote:
> > Do we end up calling the
> > macro which actually executes the option for the package?  Or are we
> > constructing a list that we pass when we input color.sty, as if we were
> > really doing
> > \usepackage[option1,option2]{color}
> No, it is more like saving in some macro the code which has
> to be executed in order to set an option, and later call
> that macro upon call to \pkgoptions{...}{...}.  I might be
> wrong, but I figured that LaTeX packages do something like
> this for every option they support:
>   \DeclareOption{hyphens}{\def\do at url@hyp{\do\-}}
> By default, miniltx.tex just makes
>   \let\DeclareOption\@gobbletwo
> so all option declarations go to waste.  Instead, we
> (re)define \DeclareOption to take the name of the option
> (the first parameter), to construct a macro name using this
> name (pkgoptions at PACKAGENAME@hyphens), and to define this
> macro to the code (the second parameter).  Later on, after
> the package will have been loaded, the user might call
> \pkgoptions{option}{pkg} to have that macro called and the
> option applied.

For many options the timing of the code is important. This is a brief
description of LaTeX's package option handling:

The \usepackage command saves the options actually used in a macro
before the package is input. In the package, \DeclareOption defines code
for each possible option. At the \ProcessOptions command, the list of
actual options is examined and the code for each such option is
executed. There might optionally be an \ExecuteOptions command whose
argument is a list of options. In the package code, this should come
before \ProcessOptions and its purpose is to establish defaults which
can then be overridden.

In url.sty there is code right after \ProcessOptions that relies on the
result of that operation. Thus, one cannot wait until after the file is
input to run the option code.

So to be able to load LaTeX packages, I think one needs to define
\ProcessOptions. And to populate the option list before loading the
package. The following simple scheme should handle many cases:

1) Before inputting the package file, create the list of options. This
could be as simple as defining a command (say \list at of@options) that
\pkgoption at PACKAGENAME@OPTION1\relax%
\pkgoption at PACKAGENAME@OPTION2\relax%

2) As above, define \DeclareOption#1#2 so that
  \pkgoption at PACKAGENAME@#1
is defined to be #2.

3) Define \ProcessOptions to execute \list at of@options and then clear its

4) Define \ExecuteOptions to recurse through the list in its argument
and execute the code for each such option.

> > (And BTW isn't xcolor better than and compatible with color?)

Since eplain is starting from scratch, so to speak, it can choose
either. What I'm not sure of is whether miniltx+xcolor is enough or
whether a lot more work might be required.


Dan Luecking
Dept. of Mathematical Sciences
University of Arkansas
Fayetteville, AR 72101

More information about the tex-eplain mailing list