8

The following code uses the etoolbox package to convert a list a,b,c into an internal list (called \mylist) and then typesets that with colons: a:b:c:. However, when I load the etextools package (by uncommenting the second line), I get no list output.

\documentclass{minimal}
\usepackage{etoolbox}
%\usepackage{etextools}
\begin{document}
A list:
\def\mylist{}
\forcsvlist{\listadd\mylist}{a,b,c}
\def\do#1{#1:}
\dolistloop{\mylist}
\end{document}

I suspect it is is a bug since etextools claims to depend on etoolbox. Is this a bug or am I doing something wrong? In either case, how can I use \dolistloop with etextools (which I want for goodies like \expandnext)?

Notes

  • \show\mylist produces the same output a|b|c| in both cases, so the problem is with \dolistloop which expands to \forlistloop\do
  • The \forlistloop command becomes substantially more complicated when etextools is used.
  • This question might be relevant (but not obviously).
3
  • The \DeclareCmdListParser\listloop{|} command in etextools.sty is responsible for changing \forlistloop. Not sure yet why this breaks the behaviour.
    – mforbes
    Mar 26, 2012 at 22:12
  • If one is committed to using etextools, then \listloop{\mylist} works where \dolistloop{\mylist} fails. I would still like code that works with and without etextools.
    – mforbes
    Mar 26, 2012 at 22:19
  • 2
    Just a note that this bug has been noticed before. I also sent a message to Florent Chervet mentioning this bug.
    – mforbes
    Mar 28, 2012 at 4:13

2 Answers 2

7

This might be a bug in the etextools package. In fact, \forlistloop is currently redefined in a way incompatible with the etoolbox package. Hence, try:

\usepackage{etoolbox}
\let\origforlistloop\forlistloop
\usepackage{etextools}
\let\forlistloop\origforlistloop
3
  • This does not explain what the problem is, but is a reasonable practical solution (though may create other issues with etextools). Hopefully the maintainer will step in, confirm the bug, and have a suggestion for fixing it.
    – mforbes
    Apr 12, 2012 at 17:44
  • @mforbes: Both the etoolbox package and the etextools package define \forlistloop, but unfortunately not with the same argument signature. This is the problem.
    – mhp
    Apr 12, 2012 at 21:07
  • @mforbes: If you need the \dolistloop of the etoolbox package, but otherwise the \forlistloop of the etextools package don’t restore \forlistloop and use \patchcmd to replace \forlistloop with \origforlistloop in the definition of \dolistloop.
    – mhp
    Apr 13, 2012 at 6:29
3

If you are willing to use catoptions package, you can do

\documentclass{minimal}
%\usepackage{etoolbox} % you may load this if you like
%\usepackage{etextools} % load if you like
\usepackage{catoptions}

\begin{document}
% Add these elements to list container \mylist:
\docommalist{a,b,c}{\cptaddtolist\mylist{#1}}

% User callback for every item in \mylist. Don't print the last colon (:):
\def\mydo#1{#1\iflastindris\else:\fi}

% Do the looping over elements of \mylist. The star (*) form of \indrisloop expects
% a macro whose top level expansion contains the list items:
\indrisloop*\mylist\mydo
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .