Saturday, January 8, 2011

Latex Wrapperclass

When you define a new class in latex you most unlikely want to start from scratch. This is of course not a problem, you can easily inherit another documentclass. Problems tend to start if you also need to react on an option of the class as well. The example shows the easiest way i know of:

\NeedsTeXFormat{LaTeX2e} 
\ProvidesClass{myartcl}[2010/01/06 This is so 2010!]
\RequirePackage[unknownkeysallowed]{keyval} 
%set up the function for finding doublesided as an argument 
\define@key{keygroup}{doublesided}[true]{% 
  % Do whatever you need to here 
  \PackageWarning{myartcl}{Found doublesided #1}% 
} 
% and we pass it on to the keyval parsing algo 
\DeclareOption*{% 
  \edef\act{\noexpand\setkeys{keygroup}{\CurrentOption}}\act% 
  \PassOptionsToClass{\CurrentOption}{article}% 
} 
\ProcessOptions\relax 
\LoadClass{article} 

No comments:

Post a Comment