I'm defining a class that extends article
that loads a package inside (automultiplechoice
). I'm trying to configure the package and the class using the parameters of the \documentclass
command.
When I test for other packages (for example hyperref
) it works (see code below).
\RequirePackage{filecontents}
\begin{filecontents*}{test.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{test}[2012/02/10 Mini class for testing proposal]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
\LoadClass{article}
% toggle this
\PassOptionsToPackage{linkcolor=blue}{hyperref}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{hyperref}}
\ProcessOptions\relax
\RequirePackage{hyperref}
\end{filecontents*}
\documentclass[colorlinks=true,legalpaper]{test}
\begin{document}
\section{Test}\label{foo}
\ref{foo}
\end{document}
However, when I change it to the automultiplechoice
package, it doesn't (see code below)
\RequirePackage{filecontents}
\begin{filecontents*}{test.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{test}[2012/02/10 Mini class for testing proposal]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
\LoadClass{article}
% with this
\PassOptionsToPackage{lang=EN}{automultiplechoice}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{automultiplechoice}}
\ProcessOptions\relax
\RequirePackage{automultiplechoice}
\end{filecontents*}
\documentclass[legalpaper,lang=ES]{test}
\begin{document}
\section{Test}\label{foo}
\ref{foo}
\end{document}
In the latter, the unknown parameters for the article
class (in this case legalpaper
) trigger an error in the package, but I would like them to be ignored. I got the error
! LaTeX Error: Unknown option
legalpaper
for packageautomultiplechoice
.
What I am missing? It has something to do with the xkeyvalue
definitions?
I would like to be able to pass parameters to the package and to the class in the same definition in \documentclass
. How can I make that happen?
article
class and which are supposed to be passed to theautomultiplechoice
package. I think you're misusing the starred\DeclareOption
, here.\DeclareOption{lang=EN}{\PassOptionsToPackage{\CurrentOption}{automultiplechoice}}
. Also, that solution has the limitation that I have to manually define all the available options, and if in the future there are more or less options I need to change my code. So, is not maintanable in time.\ProcessOptions
more than once.