I would like to write a macro (using Latex3/expl3) that can automatically refer to say plot using several key-value parameters. Here is what I currently have:
Code: Select all
\keys_define:nn{label}{
Re .tl_set:N = \l_label_Re_tl,
DOF .tl_set:N = \l_label_DOF_tl,
statsName .tl_set:N = \l_label_statsName_tl,
}
\NewDocumentCommand{\getProjOneLabel}{m}{
\keys_set:nn{label}{#1}
\newcommand{\Stat}{\StrLeft{\l_label_statsName_tl}{3}} %1st 3 letters of
fig:{\Stat}Re\l_label_Re_tl DOF\l_label_DOF_tl
}
Code: Select all
label=\getProjOneLabel{statsName=Strouhal,DOF=4M, Re=50}
label=fig:StrRe50DOF4M
which is correct. But when I use it for real referencing like this:
Code: Select all
\ref{\getProjOneLabel{statsName=Strouhal,DOF=4M, Re=50}}
??fig:StrRe50DOF4M
I think this has smth to do with order of expansion, but I don't understand expansion process fully yet. Tried putting \expandafter many times, still fails. Could smbd please explain step by step what goes wrong here?
When I hardcode label as
Code: Select all
\ref{fig:StrRe50DOF4M}
The goal is to write a macro say '\plotref' that will execute
Code: Select all
\ref{\getProjOneLabel{statsName=Strouhal,DOF=4M, Re=50}}
I am new to Latex3 and even to regular Latex/Tex, the more details the better.
Thank you very much.