8

Possible Duplicate:
Defining a wrapper class for a set of document classes

When writing a new class (say, journal), how can I base it on an existing class (say, scrbook)?

raphink
  • 31,894
  • 3
    Related: http://tex.stackexchange.com/questions/36274/defining-a-wrapper-class-for-a-set-of-document-classes – lockstep Sep 13 '12 at 06:45
  • Thanks @lockstep, this is pretty much what I would like to achieve indeed, but this question didn't show up when searching. – raphink Sep 13 '12 at 06:48

2 Answers2

13

The LaTeX Companion does explain this in more detail, but here is what you basically have to do in your journal.cls:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{journal}[2012/09/13]

\LoadClass{scrbook}

...

You need to be careful when dealing with class options. I discussed this issue when using the kvoptions key-value package in https://tex.stackexchange.com/a/68475/15616. But there are also native LaTeX commands \DeclareOption, \DeclareOption* and \ProcessOptions*.

bodo
  • 6,228
7

Besides the command \LoadClass there's a command \PassOptionsToClass{<options-list>}{<class-name>} that can be used before \LoadClass{<class-name>}. This is a simple beginning of your class:

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{myclass}[2012/09/13 v0.1 My Class]

\PassOptionsToPackage{patch}{kvoptions}
\RequirePackage{kvoptions}

\DeclareBoolOption{draft}
\ProcessKeyvalOptions*

\ifmyclass@draft
  \LoadClass[draft]{article}
\else
  \LoadClass{article}
\fi

If you want all options user gives to myclass to be passed to article, you can used \LoadClassWithOptions{article}. However, this can have some drawbacks and I'm not sure it is always a good idea.

yo'
  • 51,322