New answers tagged

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 ...


0

I find using node[leaf] {\leaf ...} works: \documentclass{article} \usepackage{tikz} \usepackage{xparse} \usetikzlibrary{trees,shapes.multipart} \NewExpandableDocumentCommand\leaf{o o o m}{ 6\nodepart{two}8\nodepart{three}2\nodepart{four}#4 } \tikzset{ btree/.style={ nodes={rectangle split,rectangle split horizontal=true,draw}, level 1/.style=...


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 ...


Top 50 recent answers are included