# Defining a wrapper class for a set of document classes

Until now, I have been collecting my "frequently used packages", custom macros, and configurations in a personal style file. However, some of those configurations depend on the use of one of the KOMA-Script classes, and therefore (according to my own answer to Classes and packages – what's the difference?) good practice stipulates that I rewrite my personal file into a wrapper class.

According to section A.4.8 of the LaTeX Companion, a wrapper class file myclass.cls that builds on article.cls and passes class options specified by the user to the base class would look like, e.g.,

\ProvidesClass{myclass}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
\RequirePackage{<package list>}


or, even easier,

\ProvidesClass{myclass}
\RequirePackage{<package list>}


However, my base class may in fact be one of several document classes, namely scrartcl, scrreprt, orscrbook. I want to define some wrapper class options (named, say, article/report/book) that, by specifying one of them, load the corresponding KOMA-Script class. (If I don't specify any of them, scrbook shall be loaded by default.) How do I go on about this?

-

This scheme seems to work:

\ProvidesClass{lockstep}
\DeclareOption{scrartcl}{\def\lock@class{scrartcl}}
\DeclareOption{scrreprt}{\def\lock@class{scrreprt}}
\DeclareOption{scrbook}{\def\lock@class{scrbook}}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\lock@class}}
\ExecuteOptions{scrbook}
\ProcessOptions\relax


The default class is scrbook, but the options scrartcl or scrreprt will change it.

In my test I tried with the abstract option:

\documentclass[abstract]{lockstep}


gives Unused global option(s): [abstract], while

\documentclass[scrartcl,abstract]{lockstep}


doesn't show the message.

-

The following works for me. I like the flexibility given by keys, but you have to \RequirePackage{kvoptions-patch} or to make your own format including it.

\begin{filecontents*}{myclass.cls}
\ProvidesClass{myclass}
\RequirePackage{pgfopts}
\pgfkeys{%
/MyClassKeys/class/.store in = \MyClass,
/MyClassKeys/class = scrbook}%
\ProcessPgfOptions{/MyClassKeys}
\end{filecontents*}

\RequirePackage{kvoptions-patch}
\documentclass[class = extarticle,14pt]{myclass}

\begin{document}

This is my class using the \MyClass{} class

\end{document}


Note that is not actually a wrapper but the class itself. If find it easier to maintain (but a .dtx can also be a good solution to maintain different files, including some wrappers).

-
I'd rather avoid the need for a \RequirePackage in actual documents, but +1 for a solution using pgfopts. –  lockstep Nov 26 '11 at 23:23