# pgfopts .unknown does not handle key-value pairs?

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]

\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.

• Welcome! On my machine not even your working example works. It does say 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?
– user194703
Feb 17, 2020 at 18:03
• @Schrödinger'scat: Thank you, of course. In my rush to minimize the MWE I deleted the \LoadClass line. The edited version works for me as described. Feb 17, 2020 at 19:12