J'utilise la commande Si je passe une chaîne de caractère en argument alors la chaîne est retournée formatée. En revanche, si je stocke la chaîne dans une commande alors la chaîne est retournée n'est pas formatée. Et je ne trouve pas la solution. \documentclass{article}% \usepackage{color} \ExplSyntaxOn% \NewDocumentCommand{\dicStr}{}{weak /bi/ strong /bi/}% \NewDocumentCommand{\dicStylePhonetic}{ m }{% \tl_set:Nn \l_tmpa_tl { #1 }% \regex_replace_case_all:nN { { (weak|strong) } { \c{textcolor}\cB\{red\cE\} \cB\{ \1 \cE\} }% } \l_tmpa_tl \tl_use:N \l_tmpa_tl% }% \ExplSyntaxOff% \begin{document}% \dicStylePhonetic{weak /bi/ strong /bi/}% \dicStylePhonetic{\dicStr{}}% \end{document}% |
La solution : \documentclass{article}% \usepackage{color} \ExplSyntaxOn% \NewExpandableDocumentCommand{\dicStr}{}{weak /bi/ strong /bi/}% \NewDocumentCommand{\dicStylePhonetic}{ m }{% \tl_set:Nx \l_tmpa_tl { #1 }% \regex_replace_case_all:nN { { (weak|strong) } { \c{textcolor}\cB\{red\cE\} \cB\{ \1 \cE\} }% } \l_tmpa_tl \tl_use:N \l_tmpa_tl% }% \ExplSyntaxOff% \begin{document}% \dicStylePhonetic{weak /bi/ strong /bi/}% \dicStylePhonetic{\dicStr{}}% \end{document}% |