I want to automatize some of the code that I usually include to setup my theorem environment
functionality into a package. So here is what I do to control within which counter my theorems are numbered:
\RequirePackage{filecontents}
\begin{filecontents}{mytheorems.sty}
\RequirePackage{xkeyval}
\RequirePackage{amsthm}
\DeclareOptionX{numberwithin}{%
\theoremstyle{plain}%
\newtheorem{theorem}{Theorem}[#1]%
}
\DeclareOptionX{nonumberwithin}{%
\theoremstyle{plain}%
\newtheorem{theorem}{Theorem}%
}
\ProcessOptionsX
\theoremstyle{plain}
\newtheorem{lemma}[theorem]{Lemma}
\end{filecontents}
\documentclass{article}
\usepackage[nonumberwithin]{mytheorems}%or use option [numberwithin=section] for example
\begin{document}
\begin{lemma}
content...
\end{lemma}
\end{document}
Now I would like that the package is loaded with [nonumberwithin]
if no option is given. However adding \ExecuteOptionsX{nonumberwithin}
to the package won't allow [numberwithin=section]
any longer because the two options clash. So what should I do?