[Tex/LaTex] How to set class options that can have multiple values

class-optionscomma-separated listdocument-classeskoma-script

Title says it all, but here's an example: the KOMA-Script classes provide the option toc which can have multiple values that don't interfere with each other, like values that enable the Bibliography in the TOC and others that just influence the layout of the TOC. When I need several of these values for the class option toc, how can I pass them all together to toc without having to repeat toc= all the time?

What I have currently:

\documentclass[toc=listof, toc=bibliography, toc=flat]{scrbook}

Idea of what I'd like to have (but what does not work)

\documentclass[toc={listof, bibliography, flat}]{scrbook}

Is this somehow possible? If yes, how?

Best Answer

The standard LaTeX \documentclass syntax doesn't use = at all, just a comma separated list of values like [12pt,twoside] so

\documentclass[toc=listof, toc=bibliography, toc=flat]{article}

would just be three (undefined) options toc=listof , toc=bibliography and toc=flat There is no mechanism for passing values to an option toc.

Some classes load keyval or similar packages and redefine \documentclass to use that so then your example passes the three values listof, bibliography and flat to the toc key defined by that class.

In your example toc={listof, bibliography, flat} the keyval parser will pass the single value listof, bibliography, flat to the toc key, but then it is up to the definition of that key in the class whether it treats this as an unknown value or whether it further processes it as a comma separated list.

Related Question