#StackBounty: #expl3 #key-value Forward list of key-value-pairs to other command in expl3

Bounty: 50

I would like to pass a list of key-value pairs to another command/environment. In this MWE to tcolorbox, but it should work in general (e.g. pass parameters to LoadClass[params]{article}).

documentclass{article}
usepackage{xparse,graphicx}

RequirePackage{tcolorbox}
tcbuselibrary{xparse}
DeclareTColorBox{mytcb}{O{}}{#1}

ExplSyntaxOn
keys_define:nn { mybodule/bfigure }
{
    caption .tl_set:N = l_mybodule_caption_tl,
    tcb     .clist_set:N = l_mybodule_tcb_clist,
}

NewDocumentEnvironment{bfigure}{O{}}
{
    keys_set:nn { mybodule/bfigure } { #1 }  
    begin{mytcb}[l_mybodule_tcb_clist]
}
{end{mytcb}}
ExplSyntaxOff

begin{document}
    begin{bfigure}[tcb={left=-3pt}]
        includegraphics[width=1cm]{example-grid-100x100pt}
    end{bfigure}
end{document}

I am not quite sure how I can achieve this. Can anyone help?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.