10

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?

2
  • 1
    Which set is smaller: those to pass through or those not to? Is one (or both) well defined?
    – Joseph Wright
    Jul 26, 2012 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.
    – zwol
    Jul 26, 2012 at 15:32

2 Answers 2

7

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}%    
}
1
  • 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.
    – zwol
    Jul 29, 2012 at 22:08
7

You can use \OptionNotUsed; for example,

\DeclareOption{12pt}{\OptionNotUsed}
1
  • 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.
    – zwol
    Jul 26, 2012 at 1:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .