[Tex/LaTex] Defining a wrapper class for a set of document classes

class-optionsdocumentclass-writing

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
\LoadClass{article}
\RequirePackage{<package list>}

or, even easier,

\ProvidesClass{myclass}
\LoadClassWithOptions{article}
\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?

Best Answer

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
\LoadClass{\lock@class}

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.

Related Question