TransWikia.com

pgfkeys: firing .unknown handler for a "parent" key

TeX - LaTeX Asked by meide on October 11, 2020

Using pgfkeys, I automatically build some subkeys when an unknown key is encountered. See MWE below.

I would like to avoid having to set the test key (which is what fires the .unknown handler) before accessing the subkeys, ie. make it implicit. Is this possible?

documentclass{article}

usepackage{pgfkeys}
usepackage{etoolbox}

pgfkeys{/handlers/.store in cs/.code=pgfkeysalso{%
    pgfkeyscurrentpath/.code=csdef{#1}{##1}}%
}

newcommandbuildkeys[1]{%
    pgfkeys{%
        /mypath/#1/a/.store in cs=my#1a,
        /mypath/#1/b/.store in cs=my#1b,
    }
}

pgfkeys{%
    /mypath/.unknown/.code={%
        edefk{pgfkeyscurrentname}%
        buildkeys{k}%
    }
}

pgfkeys{%
    /mypath/.cd,
    test, % Needed to fire the .unknown handler. I would like to avoid this
    test/a=test a,
    test/b=test b,
}

begin{document}

should be "test a": mytesta

should be "test b": mytestb

end{document}

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP