4

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
    Commented Mar 4, 2015 at 13:17

1 Answer 1

5

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? Commented May 14, 2018 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. Commented May 15, 2018 at 18:39
  • What does "unconditionally do" mean in this context?
    – jarnosz
    Commented Feb 8, 2021 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. Commented Feb 8, 2021 at 20:33
  • 1
    @jarnosz \@classoptionslist (doc in source2e.pdf ltclass chapter) Commented Feb 12, 2021 at 14:45

You must log in to answer this question.

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