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}
  • 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
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
0

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.

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.