Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have written a wrapper for the scrartcl class in the following way:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mycls}[2012/08/23]

\RequirePackage{kvoptions}

\DeclareStringOption{title}
\DeclareStringOption{subtitle}

\ProcessKeyvalOptions*

\PassOptionsToClass{fleqn, openbib, headings=big, DIV=12}{scrartcl}
\LoadClassWithOptions{scrartcl}

This way I can provide some default arguments for scrartcl like DIV=12 and still override them by passing

\documentclass{title=mytitle, subtitle=thesubtitle, DIV=10}

The problem I have, is that srcartcl marks the other options, e.g., title=mytitle as unused

LaTeX Warning: Unused global option(s)

which is certainly false. I tried unsetting the options with

\DisableKeyvalOptions{mycls}{title}

right after \ProcessKeyvalOptions*, but that didn't work. How can I mark those options as used?

share|improve this question
    
Sorry, I misread the question completely and my solution is therefore surely wrong. –  yo' Aug 23 '12 at 16:29
1  
Btw, shouldn't doing \LoadClass[fleqn, openbib, headings=big, DIV=12]{scrartcl} instead of \PassOptionsToClass and \LoadClassWithOptions help? –  yo' Aug 23 '12 at 16:31

1 Answer 1

up vote 5 down vote accepted

I took a fresh, thorough look at The LaTeX Companion (A.4.8) and solved the problem myself.

Despite what I previously assumed, \PassOptionsToClass and \LoadClassWithOptions do not work together. The whole point of \LoadClassWithOptions is passing exactly the same arguments as the current class got. So here switching to \LoadClass will now take the default options.

Unfortunately now the user given global options will not overwrite the default ones. Therefore they have to passed manually to the class. Here kvoptions provides \DeclareDefaultOption as a equivalent to the classic \DeclareOption*. All in all the result looks like:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mycls}[2012/08/23]

\RequirePackage{kvoptions}

\DeclareStringOption{title}
\DeclareStringOption{subtitle}

\PassOptionsToClass{fleqn, openbib, headings=big, DIV=12}{scrartcl}

\DeclareDefaultOption{\PassOptionsToClass{\CurrentOption}{scrartcl}}

\ProcessKeyvalOptions*

\LoadClass{scrartcl}

So whenever \ProcessKeyvalOptions* sees an unknown option, like DIV=10, it passes it along to scrartcl, overwriting any default value in the process. That's why \PassOptionsToClass had to be moved in front of it.

share|improve this answer
    
As far as the options you pass to scrartcl does not depend on the global ones, this shall work. But you should at least define the draft option for your class, something like \DeclareVoidOption{draft}{\overfullrule5\p@}. –  yo' Aug 23 '12 at 17:26
    
@tohecz: That is not necessary. Because of my use of \DeclareDefaultOption, all those global options (like draft) that I'm not handling myself, are passed on to scrartcl. –  canaaerus Aug 23 '12 at 17:29
    
Oh ok, one learns all the time, even after he's written two sort-of complex classes himself... –  yo' Aug 23 '12 at 17:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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