2

I had a tex-file that basically started as follows

\documentclass[
  a4paper, hyperref, amsmath, headinclude=true, ngerman, final
]{scrbook}
\usepackage{babel}
\usepackage{ntheorem}
\usepackage{graphix}

I converted this into my own custom class file

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{kitbook}[2015/04/23 KITbook]

\RequirePackage{kvoptions}
\SetupKeyvalOptions{family=KIT,prefix=KIT@}
...
\ProcessKeyvalOptions*\relax

\LoadClass[
  a4paper, hyperref, amsmath, headinclude=true, ngerman, final
]{scrbook}
\RequirePackage{babel}
\RequirePackage{ntheorem}
\RequirePackage{graphix}

The tex-file is reduced to

\documentclass{kitbook}

But suddenly I get a LaTeX warning that the options hyperref, amsmath, headinclude=true are unused. Babel gives the error that no language is specified and the option final is indeed used by the scrbook class but not by the graphix package.

It seems that there is a difference in the semantic of \documentclass and \LoadClass. Options that are given to \documentclass are made global and implicitely passed to all packages. But options given to \LoadClass are only used by the class itsself. That is the reason why babel does not get ngerman and so on.

Is there any way to make options global in a custom class file?

Especially, I see one major problem. The option headinclude=true is not used by any package that is explicitely loaded. (I believe it is used by typearea that itsself is loaded by scrbook.) Of course, I could use \PassOptionToPackage{headinclude=true}{typearea} but the problem with this approach is that I need to find out which package uses which option for every option and package and then call \PassOptionToPackage explicitely. This approach is not very promising.

nagmat84
  • 1,115
  • I think, it should be \LoadClassWithOptions{scrbook}? –  Apr 23 '15 at 16:16
  • 1
    No, it is not. \LoadClass{scrbook} loads the class with all options. Those options that are given as optional argument, i.e. \LoadClass[foo]{scrbook}, and those options given by \PassOptionsToClass{bar}{scrbook}. Contrary, \LoadClassWithOptions{scrbook} loads the class ONLY with those options given explicitly as optional argument, i.e. \LoadClassWithOptions[foo]{scrbook}. All options from \PassOptionsToClass{...}{...} are ignored. Particulary, \LoadClassWithOptions{scrbook} loads the class with no options at all. However, both commands pass the options to the class only! – nagmat84 Apr 24 '15 at 12:07
  • I have this exact same problem. I was excited to find your question, but disappointed to see that there is no answer. I think this problem is doubly confusing because options passed to \LoadClass will generate an Unused global option(s) warning despite the fact that they are not actually being treated as global options! – DaoWen Jun 16 '16 at 16:01
  • 1
    @DaoWen See http://tex.stackexchange.com/q/147243/2388 – Ulrike Fischer Jan 22 '17 at 19:46

0 Answers0