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)?

marked as duplicate by Martin Schröder, diabonas, clemens, Marco Daniel, egreg Sep 15 '12 at 22:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

12

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*.

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.

  • Please see the answer I linked to, for the correct way of passing options on in this case (with kvoptions). – bodo Sep 13 '12 at 6:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.