28.03.2013 Views

Guide to LaTeX (4th Edition) (Tools and Techniques

Guide to LaTeX (4th Edition) (Tools and Techniques

Guide to LaTeX (4th Edition) (Tools and Techniques

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

442 Appendix D. L AT E X Programming<br />

This system of version checking allows a document <strong>to</strong> insist that<br />

suitable versions of the class <strong>and</strong> package files are loaded. It assumes,<br />

however, that all later versions are fully compatible with earlier ones.<br />

There is a further identifying comm<strong>and</strong> for general files, those <strong>to</strong> be<br />

loaded with \input.<br />

\ProvidesFile{file name}[version]<br />

There is no checking of the name or version in this case, but both pieces<br />

of information will be printed by \listfiles.<br />

D.2.2 Loading further classes <strong>and</strong> packages<br />

In the main document file, classes are read in by means of the initializing<br />

\documentclass comm<strong>and</strong>, <strong>and</strong> packages with \usepackage. Within<br />

class <strong>and</strong> package files, the comm<strong>and</strong>s<br />

\LoadClass[options]{class}[version]<br />

\RequirePackage[options]{package}[version]<br />

\LoadClassWithOptions{class}[version]<br />

\RequirePackageWithOptions{package}[version]<br />

must be used instead. The first allows one class file <strong>to</strong> load another, with<br />

selected options, if desired; the second permits class <strong>and</strong> package files <strong>to</strong><br />

load other packages. Only one \LoadClass comm<strong>and</strong> may appear within<br />

any class file; it may not be called from a package file. Neither comm<strong>and</strong><br />

may be invoked in the document file. The packages argument may be a<br />

list of several package names, separated by commas.<br />

The ...WithOptions variants load the class or package with all those<br />

options that were specified for the current one, something that is often<br />

required.<br />

How the optional version arguments interact with the corresponding<br />

\Provides.. comm<strong>and</strong> has been explained in the previous section; how<br />

the options argument is treated is described below.<br />

D.2.3 Processing options<br />

Both classes <strong>and</strong> packages may take options which are defined with<br />

\DeclareOption{option}{code}<br />

where option is the name of the option <strong>and</strong> code is the set of instructions<br />

that it is <strong>to</strong> execute. Internally, a comm<strong>and</strong> named \ds@option is created.<br />

Often the code does nothing more than set flags, or input an option<br />

file. (\RequirePackage may not be used within the option code!) Two<br />

examples from article.cls are<br />

\DeclareOption{fleqn}{\input{fleqn.clo}}<br />

\DeclareOption{twocolumn}{\setboolean{\@twocolumn}{true}}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!