I am making a factory macro (A) that produces another macro (B). Macro B consists in affecting what it gets as parameters to variables when called. I am currently able to do all this without A, but this is not scalable, because it requires a lot of rewritting.
See Macro factory and argument passed at calling for the whole context.
Following the answers on question the previous question (Macro factory and argument passed at calling ) , I could make a new MWE with some points still opened :
- point 1 : I put comas in the
\clist_map_inline
to artificially delimit each argument - point 2 : I put the list of the argument in the definition (the 3 m) :
\NewDocumentCommand{\DefinitionVariables}{ m m m }%
- point 3 : I put all the arguments in the
\clist_map_inline
function :\clist_map_inline:nn { #1, #2, #3}%
So the questions following these changes are :
- point 1 : How can I, not have to put a comas ? I guess it has to do with the
\clist_map_inline
function, with coma being a built-in delimiter. It raises an issue when there is a coma inside an argument as the function will cut it as it considers it's a delimiter. I was thinking of having kind of a\foreach argument in {all the arguments}
. Does such a thing exist ? - point 2 : How can I make this m dynamic ? By dynamic, I mean : sometimes, the function can take 3 arguments, but sometimes it can be 7 or 9 (between 1 and 9). Something like
numberOfArgument * m
point 3 : It's related to the previous point, how can I also make this dynamic and not hard-coded ? (the
\foreach argument in {all the arguments}
would solve it).\documentclass[twoside]{article} % package pour utiliser une macro nested ac ses propres args \usepackage{xparse} \errorcontextlines32 \begin{document} %================================================================================== % Prerequisite : lines of code to define variableI to variableXVI %================================================================================== \iffalse \fi \newcommand{\DefinitVariable}[1]{% \expandafter\newcommand\csname variable\Roman{#1}\endcsname{}% }% % Loop for defining all the variable \newcounter{ctr} \loop \stepcounter{ctr} \expandafter\DefinitVariable{ctr}% \ifnum\thectr<16 \repeat %================================================================================== % Automation trial 5 : utilise la syntaxe expl3 \iftrue %\iffalse \ExplSyntaxOn \NewDocumentCommand{\DefinitionVariables}{ m m m }% <=== point 2 : there is as much 'm' as there is arguments { \int_zero:N \l_tmpa_int %\clist_map_inline:nn { #1 } \clist_map_inline:nn { #1, #2, #3}% <=== point 3 : allows not to put comas in the arguments, but rise the pb if there is comas inside the argument // { \int_incr:N \l_tmpa_int \tl_clear_new:c { variable \int_to_Roman:n { \l_tmpa_int } } \tl_set:cn { variable \int_to_Roman:n { \l_tmpa_int } } { ##1 } } } \ExplSyntaxOff \DefinitionVariables{Laetitia, 8 }{Pierre, 10}{Cedric}% <=== point 1 : coma inside the argument will be considered as a delimiter, so the mapping of variable will be wrong La variable 2 est : \variableII \\ FIN\\ La variable 1 est : \variableI \\ FIN\\ La variable 3 est : \variableIII \\ FIN\\ La variable 1 est : \variableI \\ FIN\\ \fi
Any help is very appreciate !
\variableI
should be. Should it be “Laetitia, 8”?{...}{...}
syntax? This limits you to nine arguments.