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 found some odd behavior that I can't seem to get around. I'm writing a new version of a class file I did a while ago that is based on the memoir class. Now, the memoir class has two mutually exclusive options: oneside and twoside (twoside is the default). In my class, I want oneside to be the default. So the top of my class file is:

\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesClass{mythesis}[01/01/2011, v1.0, my own thesis class]
\RequirePackage{ifthen}
\RequirePackage{calc}
\AtEndOfClass{\RequirePackage{microtype}}
%
\newboolean{@myopti}
\setboolean{@myopti}{false}
\newboolean{@myoptii}
\setboolean{@myoptii}{false}
%
\DeclareOption{myopti}{\setboolean{@myopti}{true}}
\DeclareOption{myoptii}{\setboolean{@myoptii}{true}}
%
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{memoir}}
\LoadClass[12pt,final]{memoir}
\ExecuteOptions{myopti,oneside}

 % <remainder of class code>

Which fails to make oneside the default. If, I change it to:

\LoadClass[12pt,final,oneside]{memoir}
\ExecuteOptions{myopti}

then if, in the main file I do:

\documentclass[twoside]{mythesis}

it remains in oneside mode. The only way I can get it to work is to put

\LoadClass[12pt,final]{memoir}
\ExecuteOptions{myopti}

in the class file and then specify oneside if I want that (twoside is the default, remember, since I'm loading memoir).

But I don't want to have the user need to specify oneside since I want:

\documentclass{mythesis}

to be oneside.

I don't think this is a memoir problem, it's either a LaTeX2e problem, or an I-just-don't-know-the-right-way-to-do-it problem.

Gracias

share|improve this question

1 Answer 1

up vote 6 down vote accepted

In order to do this correctly you should create an if-switch or boolean which is modified by the oneside and twoside options of your package, which then pass the final option to memoir. Note that you should process or execute your options before loading another class or package.

\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesClass{mythesis}[01/01/2011, v1.0, my own thesis class]
\RequirePackage{ifthen}
\RequirePackage{calc}
\AtEndOfClass{\RequirePackage{microtype}}
%
\newboolean{@myopti}
\setboolean{@myopti}{false}
\newboolean{@myoptii}
\setboolean{@myoptii}{false}
\newboolean{@myopt@oneside}
\setboolean{@myopt@oneside}{true}
%
\DeclareOption{myopti}{\setboolean{@myopti}{true}}
\DeclareOption{myoptii}{\setboolean{@myoptii}{true}}

\DeclareOption{oneside}{\setboolean{@myopt@oneside}{true}}
\DeclareOption{twoside}{\setboolean{@myopt@oneside}{false}}
%
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{memoir}}
\ExecuteOptions{myopti}
\ProcessOptions*
\ifthenelse{\boolean{@myopt@oneside}}
    {\PassOptionsToClass{oneside}{memoir}}
    {\PassOptionsToClass{twoside}{memoir}}
\LoadClass[12pt,final]{memoir}
share|improve this answer
    
Martin, Thanks, that makes sense, but I doubt I could have figured it out without seeing it somewhere (which I haven't) or having someone tell me. I see that I was unclear about the relation between my options and those from a loaded class, and a few other things. It's interesting that I can have the same option name as a loaded class, but not conflict. –  bev Mar 8 '11 at 13:04
    
BTW, I have the \ExecuteOptions statement in the correct place in my real code. I was just moving it around in my code to see whether, if I processed my options after I loaded memoir I could execute 'oneside' and, since memoir was loaded, it would get passed. I forgot to put it back when I pasted the code here. But thanks for your vigilence :-) . –  bev Mar 8 '11 at 13:05

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.