2

I'd like to create a new document class which inherits most of its options from the base class article, but which sets the default font option to 11pt instead of 10pt, and also defines its own new options. I'm most of the way there, but I'm having trouble getting the new class to recognize the inherited options. Currently, my class file resembles

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{newclass}

\DeclareOption{newoption}{\def\x{x}}
\PassOptionsToClass{11pt}{article}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}

\ExecuteOptions{newoption,11pt}
\ProcessOptions\relax

\LoadClass{article}

This mostly gets the job done - The default font is 11pt, and calling \documentclass[12pt]{newclass} gives a document in 12pt font. However, calling \documentclass[10pt]{newclass} does not gives a document in 10pt font. Instead, it keeps the default 11pt font.

Test file:

\documentclass
 %
[10pt] %11pt... 
%[11pt] %
%[12pt] %
{newclass}
\stop

I've also tried using something of the form

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{newclass}

\DeclareOption{newoption}{...}

\ExecuteOptions{newoption,11pt}
\ProcessOptions\relax

\LoadClassWithOptions{article}

...

This processes all of the options correctly. However, in this case the 11pt option in \ExecuteOptions doesn't seem to be recognized, and loading the calling the class without options gives a document in 10pt font.

My questions are:

  1. Why is the 10pt option not recognized when using the first method?

  2. Why are inherited options in \ExecuteOptions not recognized when using the second method?

  • 1
    Please post a complete example which can be used to reproduce the problem. – cfr Mar 4 '15 at 13:17
2

Essentially what goes wrong here is that 10pt is not declared so it gets picked up by the default option which passes 10pt to the list that will be passed to article when it is loaded.

But you also unconditionally do

\ExecuteOptions{newoption,11pt}

so 10pt and 11pt get passed to article.

article uses \ProcessOptions not \ProcessOptions* so it processes options in the order they are declared in article which means that

\documentclass[10pt,11pt]{article}

and

\documentclass[11pt,10pt]{article}

are equivalent, and both select 11pt. The effect of your class is similar, you pass both options to article and 11pt always overwrites 10pt.

In the second example \LoadClassWithOptions is not intended to be used in a class that declares its own options, it just takes the top level list of options and passes them straight to article.

  • Regarding case (1) (the use of \ProcessOptions instead of \ProcessOptions* in article (and the rest of the standard classes, I assume) is a bug or a feature? – erreka May 14 '18 at 22:23
  • @erreka why would you call it a bug? – David Carlisle May 14 '18 at 22:28
  • To tell the truth, I don't know where is the bug, or what is the feature. If I try to build a class on top of another, I don't seem to be able to change the defaults built in the parent class's \ExecuteOptions, for I should \LoadClass the parent after issuing \ExecuteOptions from my child class, so the parent class defaults prevail. – erreka May 15 '18 at 17:20
  • So, with \ProcessOptions* declaration order would matter, and in the first case [10pt,11pt], 10pt would take precedence, correct? – erreka May 15 '18 at 17:26
  • @erreka sorry I can't guess what the issue is with comments and no example on a two year old answer, please ask a new question with an example if something isn't working. – David Carlisle May 15 '18 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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