New answers tagged

3

As @PhelypeOleinik mentioned l3prefixes.csv is a good source as it lists all packages whose authors have registered L3 prefixes for their packages with us. Another possible (and probably fairly comprehensive) source, is to search for \ProvidesExplPackage across the texmf/latex tree. For me (as of today 2020-07-03) this gives 180 packages: /usr/local/texlive/...


3

You were missing a \ in tl_use:N, and \bitheader expects its argument fully expanded, so you have to expand it before passing it on. Change \bitheader{tl_use:N \tl_head} to \exp_args:NV \bitheader \tl_head and your code will work. However I made a few more (mostly cosmetic) changes to make your code obey expl3 guidelines (take a look at “The expl3 language ...


5

Spaces are ignored between tokens, because the space character is assigned category code 9 (ignored). However any non letter (more precisely, any character with category code different from 11) stops the scanning for a control word name. Thus \my func is still five tokens, precisely \my•f•u•n•c (the bullet separates tokens). Also _ and : are assigned ...


6

Whether to use \cs_new:Npn or \cs_new_protected:Npn (or variants thereof) depends on what the functions we're defining are supposed to do. Any function that performs assignments of values to variables or of meaning to functions should be protected. For instance all new, set, clear or zero functions are protected and any function that uses them should also be....


7

Short answers on your questions (feel free to ask for more details in the comments): You should really define every function (inner or not) \protected (or robust) if it has to execute code that isn't expandable. So, use \cs_new_protected:Npn for non-expandable inner functions, even if they are only called inside a macro defined with \NewDocumentCommand (but ...


8

You should do (\x)^2 to protect the possible minus sign. Without the parentheses you get -4^2 which is correctly evaluated as -16. On the other hand, you can do much better: \documentclass{article} \usepackage{expl3} \usepackage{xparse} \ExplSyntaxOn \NewExpandableDocumentCommand{\VectorMagnitude}{O{15}m} { \fp_eval:n { round ( sqrt( 0 \...


2

That is the convention used by several tex primitives, which makes it natural to follow in expl3. \string, \jobname, \detokenize, \meaning all return token lists that are catcode 12 or 10. \makeatletter and \makeatother just switch the catcode of @ between 11 and 12, are not directly related to this at all.


1

Yet another possibility: The three new commands \nxAnd, \nxOr, \nxNot allow us to define TikZ styles for visibility setting that are based on arbitrary boolean expressions as in \defVisibilityStyle{HCocmd}{\nxNot{\nxOr{\hidencircle@trigger}}} Full example: \documentclass{article} \usepackage[tikz]{ocgx2} \usepackage{keyval} \makeatletter \define@key{...


1

You are trying very hard to hide your values behind different layers of (in part not expandable) commands. If one expand everything it works: \documentclass{article} \usepackage[tikz]{ocgx2} \usepackage{keyval} \makeatletter \define@key{hidencircle}{trigger}{\edef\hidencircle@trigger{#1}}%<-- edef \newcommand{\hidencircle}[2][]{% \setkeys{hidencircle}{#...


1

unknown is a keyword. 😑 \documentclass{article} \usepackage{expl3,xparse} \ExplSyntaxOn % Declare \tl_new:N \l__mymod_keyi_tl \seq_new:N \l_mymod_keyvalue_seq % Define \keys_define:nn { mymod } { keyi .tl_set:N = \l__mymod_keyi_tl, unknown .code:n = \mymod_store:Vn \l_keys_key_tl {#1}, } \...


1

\c@page is a symbolic name for \count0; as such it's not expandable. So \prop_gput:Nnn \g_jason_environments_prop {foobar/startpage} { \g_jason_current_page_int } and \prop_gput:Nne \g_jason_environments_prop {foobar/startpage} { \g_jason_current_page_int } are completely equivalent. And they will store \g_jason_current_page_int in the property list, not ...


6

It doesn't exist because it doesn't make much practical sense. Any inaccuracy you get from a specific computation will make your code do a different thing, even if 3.1415926535897932 and 3.1415926535897931 aren't really different. For example, this: \fp_compare:nNnTF { sin(2pi) } = { 0 } { \TRUE } { \FALSE } yields false, even though analytically it ...


4

You can define \ifenvsetTF (this is a better name, in my opinion} by \tl_const:Nn \c_getenv_par_tl { \par } \NewDocumentCommand{\ifenvsetTF}{mmm} { \sys_get_shell:nnN { kpsewhich ~ --var-value ~ #1 } { } \l_tmpa_tl \tl_if_eq:NNTF \l_tmpa_tl \c_getenv_par_tl { #3 } { #2 } } Full example: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \...


4

When you execute a shell command, TeX sees it as if you had written the output of the command to a temporary (pseudo) file, and then read that file in. While reading that file, the usual rules apply: a line end is turned into a space, and an empty line is turned into a \par token. When the output of the command is empty, it is as if the file had an empty ...


0

(continued from question comments) The key point is that in \str_set:Nn \l_alph_str { \aalph { #1 } } you need to ensure \aalph { #1 } is fully expandable, then use \str_set:Ne to convert the expansion result to string and store it in \l_alph_str. Assume you can avoid \IfInteger by other (fully expandable) means, the following example shows an attempt: \...


3

The following seems to work but I didn't check many cases. \documentclass{book} \usepackage[T1]{fontenc} \usepackage{hyperref} \hypersetup{ unicode=true, bookmarksnumbered=true } %\usepackage{bookmark} \ExplSyntaxOn \newcommand\textupper{} \pdfstringdefDisableCommands { \cs_set:Npn\textupper #1{ \use:e {\text_uppercase:n {#1}} } } % if ...


2

You can't use _ in the argument for e under \ExplSyntaxOn, because _ becomes of category code 11. The best would be to define such commands outside the scope of \ExplSyntaxOn, but you can also do it inside it: \documentclass[fleqn]{article} \usepackage{xparse} \usepackage{amsmath} \ExplSyntaxOn \cs_new_protected:Npn \test_sub:n #1 { | \sb{#1} } \...


2

I don't think that it ever worked, at least I couldn't reproduce it with texlive 2018. I would setup the command outside the expl3 catcodes: \documentclass[fleqn]{article} \usepackage{xparse} \usepackage{amsmath} \ExplSyntaxOn \cs_new_protected:Npn \test_sub:n #1 { | \sb{#1} } \cs_new_protected:Npn \test_sup:n #1 { | \sp{#1} } \ExplSyntaxOff \...


Top 50 recent answers are included