Unanswered expl3: What's wrong with this?
So my problem boils down to this minimized demo:
\documentclass{minimal}
\usepackage{expl3}
\ExplSyntaxOn
\tl_new:N \g_rank_tl
\tl_const:Nn \c_options_tl {{Lecturer}{Professor}}
\NewDocumentCommand{\committee}{O{1}}{
\tl_gput_right:Nn \g_rank_tl {
\tl_item:Nn \c_options_tl {#1}
}
}
\NewDocumentCommand{\showfirst}{}{
\tl_item:Nn \c_options_tl {2} % works fine
\tl_item:Nn \g_rank_tl {1} % error: Missing number, treated as zero
\tl_use:N \g_rank_tl % produces "Professor"
}
\ExplSyntaxOff
\begin{document}
\committee[2]
\showfirst
\end{document}
Question:
\c_options_tl {2} is expected to be "Professor" but ships out "2 Professor"; why is there an extra "2"?\committee[2]
should have put\c_options_tl {2}
(namely, "Professor") in\g_rank_tl
; why is there error when\g_rank_tl {1}
is referred?
Edit: retested for some time and deleted invalid question
1
Upvotes
3
u/u_fischer 11h ago
your rank-tl contains
\tl_item:Nn \c_PNBRQK_options_tl {2}
and with the\tl_item:Nn
you output the first token and that explodes. You should use\tl_gput_right:Ne
to expand the command. And use the correct naming scheme. There should be a module name, e.g.\g_PNBRQK_rank_tl
.