5

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

\LoadClass{beamer}

\endinput

and a file using it:

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

\begin{document}

\begin{frame}
\end{frame}

\end{document}
nvcleemp
  • 1,546

2 Answers2

3

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

\LoadClass{beamer}

\endinput
egreg
  • 1,121,712
1

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

\LoadClass{beamer}

\endinput

This works for me, but maybe there is some problem I didn't think about.

nvcleemp
  • 1,546