I am quite familiar with switch (\if...\else...\fi
) now and read many questions on key-value topic, but I cannot find an example to create the options listing command like \hypersetup
, to make
\documentclass[key1=...,key2=...,key3=...]{myclass}
equivalent to
\documentclass{myclass}
\myclssetup{%
key1 = ...,
key2 = ...,
key3 = ...,
.............
}
None of these keys are boolean, and all these values helps me to do switch into different layout schemes. For instance, key1 is to set one type of cover page and key2 is to set one type of section formats. I do not need to draw something or to set some geometry properties (I don't need values of numerical parameters). I also want some default options pre-set, if the user didn't specify their options.
If I use the kvoptions package, all I know is that I probably need \newif
and \DeclareVoidOption
(kvoptions package) to create options (values), \define@key
(keyval package) and \kvsetkeys
command (keyval package) to link values and keys. However, I have been struggling to find similar and simple examples to achieve the function I need.
I think it's important to stress that I am writing a class (not package), and it will be based on another class (like book).
kvoptions
?xkeyval
has a newer version, but the usage I apply in my answer does rely on that.l3keys
is nice too, but since you're referring to an older TL version, it's perhaps not the correct tool then