I am using PGF's \foreach
on comma-separated list where the items may contain spaces; each item can be enclosed in {...}
if it contains space, that works fine. Now, what happens when there is only a single item in the list? Curiously, whitespace has (for me unexpected) influence here.
An explanation, and better yet, a way to avoid this type of input fragility, would be much appreciated.
This is parsed correcrtly:
\fooList{items={{foo, foo}
}
}
but not this one:
\fooList{items={{foo, foo}
}}
or this one:
\fooList{items={{foo, foo}}}
\documentclass{article}
\usepackage{pgffor}
\pgfkeys{
/foo/.is family,
/foo,
items/.store in=\fooItems,
items/.initial=\undefined
}
\newcommand{\fooList}[1]{
\pgfkeys{/foo/.cd,#1}
\begin{enumerate}
\foreach [var=\content] in \fooItems{\item\content}
\end{enumerate}
}
\parindent=0pt
\begin{document}
Comma-separated list works fine for two items:
\fooList{
items={
{foo, foo},
{bar, bar}
}
}
Single item is understood when written with trailing newlines
\fooList{items={{foo, foo}
}
}
It gets incorrectly split when written like this:
\fooList{items={{foo, foo}
}}
And also when fully compacted:
\fooList{items={{foo, foo}}}
\end{document}
\usepackage
instead of\include
in the preamble.