I'm writing a custom document class. It's kinda simple, but it will use the geometry package to set page size, orientation and margins. However... Whenever I use that package, the \ExecuteOptions command stops working. Look at this minimalist testcase:

File: myclass.cls



    includehead, includefoot,
    headheight=23mm, headsep=5mm, footskip=1.5em]{geometry}

\DeclareOption{landscape}{\geometry{landscape, top=12mm, bottom=12mm, left=15mm, right=15mm}}
\DeclareOption{portrait}{\geometry{portrait, top=15mm, bottom=15mm, left=12mm, right=12mm}}

File: doc.tex

% This works: \documentclass{myclass}
% This does not work: \documentclass[foobar]{myclass}
% This does not work: \documentclass[landscape]{myclass}
% This does not work: \documentclass[anythingITypeHere]{myclass}

\title{Simple testcase}


Simple experiment... I think it should have worked.


Error message:

! Undefined control sequence.
\ExecuteOptions ...eserved@a \CurrentOption \@nil 

l.19 \ExecuteOptions{portrait}

If I don't pass any option to the \documentclass command, then it compiles. However, if I try to pass anything (like in the example above), it fails with that weird message.

If I comment out \usepackage[...]{geometry}, and replace \geometry with something else, then it compiles. So, I'm quite sure this package is messing with \ExecuteOptions command.

If I put both \DeclareOption and \ExecuteOptions before importing the package, I get an error about undefined \geometry (as expected).

If I put \DeclareOption before the \usepackage, and leave \ExecuteOptions after it, then I get an error about importing a package inside the Options section.

So... the question is how to implement document class options while still using geometry package? In other words, how to make the above code work?



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.