I am sorting some tokens in a token list using the nice features of latex3 (see below command \nom). These tokens can be sometimes empty, and when they are empty they would trigger different conditions within another command, below called \amc. The problem is that when receiving the arguments in \amc they are not detected as empty. Thus, the condition is never triggered.
I have already tried with passing within \clist_if_empty:NTF \l__wdsgn_notation_subscript_clist {**HERE**} { \clist_use:Nn \l__wdsgn_notation_subscript_clist {,} }
- An empty field
{} - An empty constant
\c_empty_tl, and - No value token
\c_novalue_tl(current implementation below)
and
\tl_if_empty:nTF,\tl_if_blank:nTF, and\tl_if_eq:nnTF(current implementation below)
without success.
Here you find the minimal working example:
\documentclass{article} \usepackage{amssymb, amsmath} \usepackage{xparse} \ExplSyntaxOn \keys_define:nn { notation/nom } { A .tl_set:N = \l_wdsgn_notation_A_tl, B .tl_set:N = \l_wdsgn_notation_B_tl, C .tl_set:N = \l_wdsgn_notation_C_tl, A .initial:n = {}, B .initial:n = {}, C .initial:n = {}, } \NewDocumentCommand{\nom}{ m O{} } { \group_begin: \wdsgn_notation_nom:nn { #1 } { #2 } \group_end: } \clist_new:N \l__wdsgn_notation_subscript_clist \cs_new:Nn \wdsgn_notation_nom:nn { \keys_set:nn { notation/nom } { #2 } % Gerneration of subscript list \clist_put_right:NV \l__wdsgn_notation_subscript_clist \l_wdsgn_notation_A_tl \clist_put_right:NV \l__wdsgn_notation_subscript_clist \l_wdsgn_notation_B_tl \amc{#1} { \clist_if_empty:NTF \l__wdsgn_notation_subscript_clist {\c_novalue_tl} { \clist_use:Nn \l__wdsgn_notation_subscript_clist {,} } } { % here we exploit the fact that \clist_use:Nn disregards empty items \clist_if_empty:NTF \l_wdsgn_notation_C_tl { \c_novalue_tl } { \l_wdsgn_notation_C_tl } } } \NewDocumentCommand \amc { m m m } { (#1) -- \tl_if_eq:nnTF {#2} {\c_novalue_tl} {empty} {not empty} -- \tl_if_eq:nnTF {#3} {\c_novalue_tl} {empty} {not empty} } \ExplSyntaxOff \begin{document} \begin{align} \nom{K}[A=A, B=B] \\ \nom{K}[A=A] \\ \nom{K}[B=B] \\ \nom{K}[C=guid] \end{align} \end{document} As you can see empty is never printed when either #1 or #2 are empty.
Output:
Thanks in advance for the help.


\clist_use:Nndoesn't disregard empty elements,\clist_use:nnwould.\clist_if_empty:NTF \l_wdsgn_notation_C_tlis wrong, that should be\tl_if_empty:NTF \l_wdsgn_notation_C_tl, and is unnecessary if you then check for emptiness in the next step again.\amcon a document level? If not, I'd say you should also give it an L3 name and not define it with\NewDocumentCommand.\clist_if_empty:NTF \l_wdsgn_notation_C_tl is wrong, that should be \tl_if_empty:NTF \l_wdsgn_notation_C_tlis actually another clist, in the real implementation i have at least 4 clists. I just wanted to simplify the problem. Comment 3:\nomis actually i use it to sort the inputed elements,\amcin this case is a place holder for another function that i call to generate some equations base of the inputs sorted and grouped bynom. This\amccommand has at least 8 inputs.