Tag Info

New answers tagged

5

Ian Thompson's code is good, but you could add the check whether you can define a new length in the first place; calling, say, \deflen{textwidth}{6pt} would issue an error message at \newlength, but it would set \textwidth nonetheless. Since you are in a style file you don't need \makeatletter for @ commands, so you can do \newcommand{\deflen}[2]{% ...


11

You need to assemble the control sequence name before defining with \newcommand, and before using it. This can be achieved using \expandafter twice. \newcommand{\deflen}[2]{% \expandafter\newlength\csname #1\endcsname \expandafter\setlength\csname #1\endcsname{#2}% } \deflen{mylength}{12pt} \showthe\mylength


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


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


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


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][,]{% ...


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



Top 50 recent answers are included