# \seq_use:Nn gets ! Missing = inserted for \ifnum

My primary problem is that I'm getting "! Missing = inserted for \ifnum." from \seq_use:Nn. My secondary problem is that I'm getting unexpected terminal reads. I've tried commenting out the parentheses and deling the \ in \exists, but neither helps.

\documentclass{article}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
%See interface3.pdf

\ExplSyntaxOn

\NewDocumentCommand{\uqualg}{mm}
{
\msg_term:n{Enterring~uqualg}
% Set option defaults
\bool_if_exist:NTF \style_qual_parens
{}
{\bool_gset_false:N \style_qual_parens}
\bool_if_exist:NTF \style_qual_paren_pairs
{}
{\bool_gset_false:N \style_qual_paren_pairs}
\bool_if_exist:NTF \style_qual_subscript
{}
{\bool_gset_false:N \style_qual_subscript}

\bool_if:NTF \style_qual_subscript
{
\seq_set_split:Nnn \l_tmpa_tl {\\} {#1}
\tl_show:N \l_tmpa_tl
\bool_if:NTF \style_qual_parens
{(\exists \sb {\l_tmpa_tl})#2}
{\exists \sb {\l_tmpa_tl} #2}
}
{
\msg_term:n{No~subscript~for~#1~}
\tl_set:Nn \l_tmpa_tl {#1}
\msg_term:n{l_tmpa_tl=\l_tmpa_tl~}
\msg_term:n{test~paren~pairs~}
\bool_if:NTF \style_qual_paren_pairs
{
% Parens around each qualifier
\msg_term:n{Pair~of~parens~around~each~item~in~#1~}
\text{Pair~of~parens~around~each~item~in~#1~}
\tl_show:N \l_tmpa_tl
{
(
\msg_term:n{open~paren}
\exists
\msg_term:n{exists}
\seq_use:Nn \l_tmpa_tl
{
)
\exists
(
}
\msg_term:n{seq_use}
)
}
{#2}
\msg_term:n {seq_us~ OK}
}
{
\msg_term:n{No~multiple~parens~}
\bool_if:NTF \style_qual_parens
{
%parens around string of qualifiers
\msg_term:n{Single~pair~of~parens~for~#1~}
(
\tl_map_inline:Nn {#1}
{
\exists {##1}
}
) #2
}
{
% Bare qualifier
\msg_term:n{no~parens~for~#1~}
\tl_map_inline:Nn {#1}
{
\msg_term:n{item~##1~}
\exists ##1
}
{#2}
}
}
}
}

\ExplSyntaxOff

\begin{document}

$\uqualg {{X}} {P(X)}$

$\uqualg{{X}{Y}} {P(X,Y)}$

\ExplSyntaxOn
\bool_gset_false:N \style_qual_paren_pairs
\bool_gset_true:N \style_qual_parens
\ExplSyntaxOff

$\uqualg {{X}} {P(X)}$

$\uqualg{{X}{Y}} {P(X,Y)}$

\ExplSyntaxOn
\bool_gset_true:N \style_qual_paren_pairs
\bool_gset_false:N \style_qual_parens
\ExplSyntaxOff

$\uqualg {{X}} {P(X)}$

$\uqualg{{X}{Y}} {P(X,Y)}$

\end{document}


Note: nothing in the expl3 documentation of \tl_show:N suggests a terminal read.

The error occurs in the call to \seq_use:Nn at line 43 inserting the string ) \exists (.

*************************************************
* Enterring uqualg
*************************************************
*************************************************
* No subscript for {X}{Y}
*************************************************
*************************************************
* l_tmpa_tl={X}{Y}
*************************************************
*************************************************
* test paren pairs
*************************************************
*************************************************
* Pair of parens around each item in {X}{Y}
*************************************************
> \l_tmpa_tl={X}{Y}.

l.112 $\uqualg{{X}{Y}} {P(X,Y)}$
?
*************************************************
* open paren
*************************************************
*************************************************
* exists
*************************************************
! Missing = inserted for \ifnum.
{
l.112 $\uqualg{{X}{Y}} {P(X,Y)}  • Why are you setting a token list variable to a sequence? – egreg Sep 19 '16 at 21:09 • The code comes from the answer to another question, and seems to work in other contexts. I couldn't find an equivalent to \use_seq:Nn for token lists, and it seemed reasonable that there would be an automatic conversion. I also couldn't find a transfer function. However, taking another look at your code I see that you were using \seq_set_split:Nnn as a transfer function, so I'll try that. – shmuel Sep 19 '16 at 21:20 • I'll repeat myself: try and explain precisely what your aim is. There are many ways to skin a cat, so you can get better suggestions. Your code is confused and badly written. – egreg Sep 19 '16 at 21:23 • My aim is to take a token list containing, e.g., {foo}{bar}{baz} and to emit (\exists foo) (\exists bar) (\exists baz). Are you suggesting that \tl_map_inline:Nn is a better way to do that? – shmuel Sep 19 '16 at 21:35 • I don't understand what you question is now that you've edited it. Originally, you wanted help re. errors. But if the code works, what is the question now? [Note that you shouldn't edit questions to include answers as it makes things very confusing!] – cfr Sep 22 '16 at 21:20 ## 2 Answers Does this satisfy you? I think you should clearly explain what you want to do. \documentclass{scrartcl} \usepackage{amssymb} \usepackage{mathtools} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand \uqualg { m m } { \shmuel_uqual:nn { #1 } { #2 } } \NewDocumentCommand \setupuqualg { m } { \keys_set:nn { shmuel / uqualg } { #1 } } \keys_define:nn { shmuel / uqualg } { subscript .bool_gset:N = \g_uqual_scrpt_bool , singleparens .bool_gset:N = \g_uqual_snglparen_bool , multiparens .bool_gset:N = \g_uqual_multparen_bool , } \cs_new_protected:Npn \math_sb:n #1 { \c_math_subscript_token { #1 } } \cs_new_protected:Npn \shmuel_uqual:nn #1 #2 { \seq_set_split:Nnn \l_tmpa_seq { } { #1 } \bool_if:NTF \g_uqual_scrpt_bool { \bool_if:NT \g_uqual_snglparen_bool ( \exists \math_sb:n { \substack { \seq_use:Nn \l_tmpa_seq { \\ } } } \bool_if:NT \g_uqual_snglparen_bool ) } { \bool_if:NTF \g_uqual_multparen_bool { ( \exists \seq_use:Nn \l_tmpa_seq { ) ( \exists } ) } { \bool_if:NT \g_uqual_snglparen_bool ( \seq_map_inline:Nn \l_tmpa_seq { \exists ##1 } \bool_if:NT \g_uqual_snglparen_bool ) } } #2 } \ExplSyntaxOff \begin{document} \[ \uqualg {X} {P(X)}$
$\uqualg {XY} {P(X,Y)}$

\setupuqualg{singleparens}

$\uqualg {X} {P(X)}$
$\uqualg {XY} {P(X,Y)}$

\setupuqualg{multiparens}

$\uqualg {X} {P(X)}$
$\uqualg {XY} {P(X,Y)}$

\setupuqualg{subscript}

$\uqualg {X} {P(X)}$
$\uqualg {XY} {P(X,Y)}$

\setupuqualg{subscript,singleparens=false}

$\uqualg {X} {P(X)}$
$\uqualg {XY} {P(X,Y)}$

\end{document}

• I'll have to think about the suggestion from @egreg to use clist. Also, there are some things that I don't understand about the code, e.g., why you define \math_sb instead of just using \sb. Some other things may become clear after I read the descriptions of the commands that you're using. Certainly your code seems to be more compact, which is good. – shmuel Sep 19 '16 at 23:03
• I would definitely use \clist_map_inline:nn as he says. I prefer {a,x,q} rather than {axq} (this one is cryptic) or {{a}{x}{q}} (this one is difficult to write and to read). {a,x,q} is simple, and clear. I define \math_sb:n to have an expl3 version of \sb. I'm using exactly your commands, except for may be the l3keys but you can forget about that, that's just an interface for setting the booleans, and may be the T(true) variants of \bool_if:NT rather than TF (true false). – Manuel Sep 19 '16 at 23:11

[This is just a supplement so I can format it properly. It answers the current question as explained in the comments on that question, rather than the original question which was addressed by Manuel.]

The explanation of what _show macros do is more detailed on page 17 when the first such example is introduced.

\cs_show:N <control sequence>


Displays the definition of the <control sequence> on the terminal.

TeXhackers note: This is similar to the TeX primitive \show, wrapped to a fixed number of characters per line.

So the behaviour is expected to be similar to that of \show and friends, which all pause compilation in order to show something on the terminal.