Passing key value pairs to a class with pgfopts

I'm trying to pass a key-value-pair to a class using pgfopts. The file testclass.cls:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{testclass}[A Testclass]

\RequirePackage{pgfkeys}
\RequirePackage{pgfopts}

\pgfkeys{testclass/testkey/.initial=testkeyinitial}
\pgfkeys{testclass/.is family}

\ProcessPgfOptions{/testclass}

\pgfkeys{testclass, testkey/.get=\optiontest}


And the file test.tex:

\documentclass[testkey=Works!]{testclass}

\begin{document}
\optiontest
\end{document}


Trying to compile test.tex gives the following error:

(./testclass.cls
Document Class: testclass A Testclass
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/pgf/utilities/pgfkeys.sty
(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.code.t
ex))) (/usr/share/texlive/texmf-dist/tex/latex/pgfopts/pgfopts.sty))
! Missing number, treated as zero.
A
l.2

?


When slightly change the above from class to package it works ... what am I missing? Many thanks in advance! Is it not possible to use pgfopts with classes?

• You need to start the optional argument to \ProvidesClass with a date ... – Joseph Wright Dec 3 '16 at 21:12
• @Joseph Wright Thank you very much, that solved the problem. – jules Dec 3 '16 at 23:17

The syntax for \ProvidesClass requires that the first part of the optional 'description' argument is a date in the form YYYY/MM/DD. There's no check that this is there something of the right form: the required text is passed through directly to be used as numbers. As such, if there are no numbers things go wrong, as you've seen. So the fix is to either omit the optional argument or to include something of the right form (can be 0000/00/00).