2

Based on this answer I'm able to verify that an option was set to specific values. But how do I verify that an option was set in case the actual value doesn't matter. I.e. how do I make sure an option is actually set to some value?

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{testclass}[2017/02/14 v1.0 My test class]
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
    family=TEST,
    prefix=TEST@
}
\DeclareStringOption{testoption}
\ProcessKeyvalOptions*
% ... how do I verify that testoption was set?
0

\DeclareStringOption uses the empty string as initial value for the option value as default. The following example sets the initial value to \relax, thus that this can be checked after the option processing:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{testclass}[2017/02/14 v1.0 My test class]
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
    family=TEST,
    prefix=TEST@
}
\DeclareStringOption{testoption}
% Override initial value for option `testoption`
\let\TEST@testoption\relax
\ProcessKeyvalOptions*

\ifx\TEST@testoption\relax
  \ClassWarning{testclass}{Option `testoption' is not set.}
\else
  \typeout{Option `testoption' is set to `\TEST@testoption'.}
\fi
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy