# Prevent passing of options when defining a new class

I'm defining a new class. In this class I created an option total. This however breaks the document since apparently this option is passed to the geometry package, even though I'm not specifying this should happen. I thought that options were only passed in case this was explicitly done using \PassOptionsToPackage or \RequirePackageWithOptions. How can I prevent this from happening? My current work around has been to change the name of the option, but I don't like that. Who knows what will break in the future?

Below is a minimal (non-)working example.

The class definition:

% example.cls
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{example}

\DeclareOption{total}{}

\ProcessOptions\relax

\endinput


and a file using it:

% test.tex
\documentclass[total]{example}

\begin{document}

\begin{frame}
\end{frame}

\end{document}

• you'd need to remove it from \@classoptionslist – David Carlisle Jan 26 '15 at 12:21
• OK, I had a look at how I should do this, and got something working. I will post it as an answer, so people can verify whether it is the best way. – nvcleemp Jan 27 '15 at 15:45

You have to remove total from \@classoptionslist; the easiest method is using expl3:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{nvcleemp}

\DeclareOption{total}{}

\ProcessOptions\relax

\RequirePackage{expl3}
\ExplSyntaxOn
\tl_remove_all:Nn \@classoptionslist {total}
\ExplSyntaxOff

\endinput


Following the comment by David Carlisle, I came up with this answer:

% example.cls
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{example}

\DeclareOption{total}{}

\def\temp@classoptionslist{}

\DeclareOption*{%
\xdef\temp@classoptionslist{\temp@classoptionslist,\CurrentOption}%
}

\ProcessOptions\relax

\let\@classoptionslist\temp@classoptionslist