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'm writing a wrapper document class that starts with article and adds a bunch of customizations (required for a particular journal style). One of the requirements is to lock down certain options:

\documentclass{thisjournal}

should behave the same as

\documentclass[10pt,twocolumn,letterpaper]{article}
% plus some more stuff

and

\documentclass[12pt]{thisjournal} % or 'onecolumn', or 'a4paper, etc

should produce an error message, but other options should be passed through, e.g.

\documentclass[draft]{thisjournal} % should turn on overfull rules

I've gotten as far as

\ProvidesClass{thisjournal}
\DeclareOption{12pt}{\ClassError{testclass}{Ten point text is required.}}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
\LoadClass[10pt,twocolumn,letterpaper]{article}

but I am unenthusiastic about having to write \DeclareOption boilerplate for every possible font and paper size option other than 10pt and letterpaper. (Is it even possible to enumerate that set?) Surely there is a better way?

share|improve this question
1  
Which set is smaller: those to pass through or those not to? Is one (or both) well defined? –  Joseph Wright Jul 26 '12 at 6:26
    
The locked-down options are the ones I showed: 10pt, letterpaper, and twocolumn. I have no idea how many other options article.cls has, and people probably do still want to use the generic "options on the \documentclass line get passed to all packages even if not recognized as class options" mechanism. –  Zack Jul 26 '12 at 15:32
add comment

2 Answers 2

up vote 7 down vote accepted

Expanding on Gonzalo's answer, you can iterate through the options you want to kill. (As th base classes do not use key-value methods, it's not like you only have to kill the 'key' part, regrettably.)

\@for\@tempa:=10pt,12pt,14pt,letterpaper,a4paper,onecolumn,twocolumn\do{%
  \DeclareOption{\@tempa}{\OptionNotUsed}%    
}
share|improve this answer
    
For other reasons I suspect I am going to have to start from scratch, after all; but this seems like the best answer to the question as posed. –  Zack Jul 29 '12 at 22:08
add comment

You can use \OptionNotUsed; for example,

\DeclareOption{12pt}{\OptionNotUsed}
share|improve this answer
    
That makes the boilerplate less repetitive, but there's still a couple dozen \DeclareOption lines to write; it's that that I'm hoping to avoid somehow. –  Zack Jul 26 '12 at 1:56
add comment

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.