3

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
  • 1
    Please post a complete example which can be used to reproduce the problem.
    – cfr
    Mar 4 '15 at 13:17
4

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.

6
  • @erreka why would you call it a bug? May 14 '18 at 22:28
  • @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. May 15 '18 at 18:39
  • What does "unconditionally do" mean in this context?
    – jarnosz
    Feb 8 '21 at 20:29
  • I mean the code passes 11pt without checking if 10pt or 12pt has been specified by the document author, so article class ends up seeing both options. Feb 8 '21 at 20:33
  • 1
    @jarnosz \@classoptionslist (doc in source2e.pdf ltclass chapter) Feb 12 '21 at 14:45

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.