I would like my custom class to forward unknown keys to the base class, or in this case, a package.
The following works (to make the example smaller, this forwards only one key; expanding it to a list would clutter the code):
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mwe}[2020/02/17 MWE]
\LoadClass{beamer}
\RequirePackage{pgfopts}
\def\@unknownkeys{}
\pgfkeys{
/mwe/.cd,
.unknown/.code={
\message{mwe found unknown key: \pgfkeyscurrentname}
\edef\@unknownkeys{\pgfkeyscurrentname}
}
}
\ProcessPgfPackageOptions{/mwe}
\relax
\PassOptionsToPackage{\@unknownkeys}{geometry}
\RequirePackage{geometry}
Now the following document:
\documentclass[showframe]{mwe}
\begin{document}
foo
\end{document}
displays a frame, as expected.
But if I modify my code by replacing
\edef\@unknownkeys{\pgfkeyscurrentname}
by
\edef\@unknownkeys{\pgfkeyscurrentname=\pgfkeyscurrentvalue}
then it does not work anymore:
\documentclass[paper=a0paper]{mwe}
\begin{document}
foo
\end{document}
gives me a DIN-A4 document. What's more, the custom message does not appear in the log, showing that the .unknown/.code was never executed at all.
Why is this? Am I doing something wrong?
PS: I originally had code similar to that provided in this answer, but that does not work, as you can see above.
Edit: forgot a line in my MWE.
mwe found unknown key: showframe
, as you describe, but then terminates with the error! Package geometry Error: \paperwidth (0.0pt) too short.
. What am I doing wrong?