# Why does biblatex not process global options

For some reason biblatex doesn't seem to be reading global options. The following tex file produces a single citation, but not in the authoryear style. If I uncomment the PassOptionsToPackage line, it works appropriately, but I'd like to pass the options directly in the class definition. Is there a reason for why the style option isn't getting read by biblatex? biblatex does seem to be processing the backend=biber option, because it doesn't produce a warning indicating that no backend was specified, which it does when that option is removed.

\RequirePackage{filecontents}

\begin{filecontents}{myclass.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{myclass}[2016/10/18 1.0 current]
\RequirePackage{biblatex}
\end{filecontents}

\begin{filecontents}{references.bib}
@article{hello,
title={Hello World},
author={Bar, Foo},
journal={Baz},
year=2016,
}
\end{filecontents}

%\PassOptionsToPackage{style=authoryear}{biblatex}
\documentclass[backend=biber,style=authoryear]{myclass}
\bibliography{references}
\begin{document}
\textcite{hello}
\printbibliography
\end{document}

• @moewe I'm not sure exactly what you mean by "Passing options to your class will not automatically pass the relevant options on to the respective packages loaded in that class". From my understanding, the options used when loading a class go to a special global options locations that can be read by all loaded packages (see tex.stackexchange.com/questions/223280/… for partial description). Indeed, for other packages this seems to work, e.g. options for hyperref. The fact that it seems to specifically not work with biblatex is why I'm confused. – Erik Oct 18 '16 at 20:35
• @moewe I also agree that that forcing a specific bib management is not ideal, but for the class file I'm creating I need to customize how the bibliography is displayed, and modify other aspects of the document when the relevant command is called. Given that biblatex is the more modern reference handler, and printbibliography is easy to override this seemed like the obvious direction to go, but it does leave a lot to be desired. – Erik Oct 18 '16 at 20:38
• Oh yes I was confused sorry. Maybe, not entirely sure since I haven't looked at the code, it has to do with the fact that some options are mandatory at loading time. – moewe Oct 18 '16 at 21:00
• As for your first comment, biblatex obviously isn't set up to read these supposedly global options. As for your second and third comments, the 'reason' for your needs are unclear, so it's hard to suggest solutions. Obviously (or so I would say) if the class is meant to be able to load any combination of biblatex options, there is not much gain over just letting people load biblatex however they want. (And I'd say class-writing is meant to be tedious so document-writing is not -- one should invest the time to do it correctly.) And what is 'ref manager' in your third comment? – jon Oct 19 '16 at 1:05
• Loading a very specific package that needs many options in a class file, especially since LaTeX has the problem of the order of loading packages, makes that task hard to deal with. I would not recommend to load biblatex in the class. Same for hyperref. On the other hand, if you want to force something special, it is not the user who has the right to decide. – Johannes_B Oct 19 '16 at 6:21

Global options are stored in \@classoptionslist. The \ProcessOptions command in a package checks this lists and compares every entry with the list of declared options of the package. If the option is known, it is executed.

But style=authoryear is not a declared, known option of biblatex. The package doesn't contain a long list of \DeclareOption{style=authoryear}{...}, \DeclareOption{style=authortitle}{...} settings. This would be neither practical nor flexible enough: after all external packages can define their own styles.

So biblatex uses a clever trick: It changes with \DeclareOption* the handling of unknown options. By default LaTeX issues \@unknownoptionerror for unknown options, but biblatex passes all options to the keyval handler.

This means that by default global options are ignored. You could pass them to biblatex, but if the option list contains options not known by biblatex you would get errors. So you will have either to "declare" all the potential options for biblatex, or change the key handler of biblatex. E.g. like this

\documentclass[style=authoryear,german]{book}

\usepackage{kvoptions}
\makeatletter

\let\setkeys\kvsetkeys
\kv@set@family@handler {blx@opt@pre} {\PackageWarning{biblatex}{Unused option #1}}

\PassOptionsToPackage{\@classoptionslist}{biblatex}
\usepackage{biblatex}