# Tag Info

19

The insertion of the “frozen \relax” is not documented in the TeXbook, where \relax appears 57 times, mostly in listings. No mention of this insertion is made in the discussion of conditionals. The insertion is documented in section 12.5.3 of TeX by Topic: Of course it's in “TeX the program”: module 510 describes the insertion in incomplete conditionals. ...

10


8

I love using counters! Here only the expansion after the number specified in \changedefinitionafter is modified. \documentclass{article} \pagestyle{empty}% for cropping \makeatletter \newcount\count@foo \newcount\nth@foo \newcommand\changedefinitionafter[4]{ % #1: name of macro % #2: exceptional occurence % #3: normal expansion % #4: ...

6

I am unsure if posting this as an answer to my own question is kosher since it does not really answer it but I will not flag it as such (even assuming I could) so if anyone has a flash of inspiration that solves the original problem, I will gladly label it as a true answer. Now about the macros. I apologize in advance for the shape they are in. They have ...

6

You don't want \tl_to_str:N and most of all you don't want to put \tl_to_str:N \l_thedate_tl into the property list, but the value of the token list variable. So \prop_gput:cnV is your friend: \documentclass{article} \usepackage{expl3,xparse} \ExplSyntaxOn \tl_new:N \l_seamus_thedate_tl \NewDocumentEnvironment{Day}{m}{ \tl_set:Nn \l_seamus_thedate_tl ...

6

You get ! Missing = inserted for \ifnum. because \repeat has \ifnum#1>\z@ so #1 has to expand to a number, but it is \repeat{2}{1} which includes many non expandable constructs such as \@repeat, \relax and \advance. Also although unrelated to the error in this fragment, it is a very bad idea to redefine \repeat as it is part of the basic \loop ...

4

TeX doesn't expand arguments when it's absorbing them. So in the second case the argument that's passed to \SplitArgument is \someStuff that doesn't contain semicolons. One might force the expansion of the first token in the argument, but this might create other problems. A lower level solution. \documentclass{article} \usepackage{xparse} \ExplSyntaxOn ...

4

No counter, but three macros for each command of this type: \documentclass{article} \makeatletter \newcommand{\newchangingcommand}[4]{% % #1 = macro name % #2 = steps % #3 = value until step #1 % #4 = value from step #1 \@namedef{\string#1@counter}{0}% \@namedef{\string#1@limit}{#2}% \def#1{% % step the counter ...

3

David has already explained why the nested \repeat command can't work and also why it's a bad idea to use the name \repeat. Here's a different definition, based on expl3: I'd say it's way easier, judge for yourself. \documentclass{article} \usepackage{expl3} \ExplSyntaxOn \cs_set_eq:NN \xrepeat \prg_replicate:nn \ExplSyntaxOff \begin{document} ...

3

This might be done with pure expansion, but since you're using xstring it's not really necessary: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\mylist}{ m o } { \clist_clear:N \l_tmpa_clist \clist_map_inline:nn { #1 } { \clist_put_right:No \l_tmpa_clist { ##1 } } \IfNoValueTF{#2} { \l_tmpa_clist } { ...

2

Try the following: \documentclass{article} \usepackage{etoolbox} \makeatletter \def\ifemptyarg#1{% http://tex.stackexchange.com/a/58638/5764 \if\relax\detokenize{#1}\relax % H. Oberdiek \expandafter\@firstoftwo \else \expandafter\@secondoftwo \fi} \makeatother \providecommand{\listcomma}{} \newcommand{\mylist}[2][,]{% ...

Only top voted, non community-wiki answers of a minimum length are eligible