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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 2 down vote accepted

share|improve this answer

Your Answer


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.