The somedefs toolkit package

Alan Jeffrey

v0.03

Overview

This is an example ‘programmers toolkit’ package, for use by package writers. It allows package writers to provide options which switch definitions on and off. For example, a package fred might define a large number of commands, including

\foo and \baz, so:
    \usepackage{fred}

would use a lot of memory, even if \foo and \baz were the only commands needed. However, if the author of fred used the somedefs package, then the user would be able to say:

    \usepackage[only,foo,baz]{fred}

and only the commands \foo and \baz would be defined.

To use the somedefs package in your own packages or classes, you say:

    \RequirePackage{somedefs}

You can then use four new commands:

• \UseAllDefinitions which says that all the commands in the file should be defined.

• \UseSomeDefinitions which says that only the commands specified by \UseDefinition should be defined.

• \UseDefinition{⟨name⟩} which says that the command \name should be defined.

• \ProvidesDefinition{⟨definition⟩} which provides one definition, of the

     form \definingcommand{\command}...

For example, the package fred could say:

    \RequirePackage{somedefs}
    \UseAllDefinitions
    \DeclareOption{only}{\UseSomeDefinitions}
    \DeclareOption*{\UseDefinition{\CurrentOption}}
    \ProcessOptions
    \ProvidesDefinition{\newcommand{\foo}{...}}
    \ProvidesDefinition{\newcommand{\baz}{...}}

One of the commands \UseAllDefinitions or \UseSomeDefinitions should al-

ways be used. You may have some commands which need other commands, in which case you have to declare the options by hand. For example, if the command \bar needs the command \foo, you could say:

    \DeclareOption{bar}{\UseDefinition{bar}\UseDefinition{foo}}

For a longer example of the use of the somedefs package, look at the rawfonts package.