# Documentation of loop over item

In this answer there is a loop construct used called loop over item. I am looking for a documentation of this and for a reference in which file it is defined.

 \ifdate{workday} {
\tikzset{every workday/.try, vacation name=,
loop over item/.code args={##1/##2/##3}{%
\ifdate{between=##1 and ##2}{%
\tikzset{every vacation/.try, vacation name/.expanded=##3}%
}{}},
loop over item/.list/.expanded=\vacations}%
}{}


I already searched the tikz documentation for it and grepped my texlive directory but didn't find it.

• The .list thingy is explained on page 890 of the pgfmanual. The whole section 82 is a great reference for the pgfkeys, which are at work here. As far as I understand things, the .list key makes the key before loop over whatever is after the = sign (\avations in this case, which also gets expanded because of the .expanded key). BTW, as far as I understand things, this loop over item by itself is, despite what its name suggests, not a loop, but "just" a code. However, due to the .list key, it becomes a loop – user121799 Sep 27 '18 at 19:46
• loop over item/.code=blah suggests that it is a user-defined macro. There should not be documentation. – Symbol 1 Sep 27 '18 at 21:02

Everything I am going to say here is much better explained in section 82 of the pgfmanual. loop over item by itself is, despite what its name suggests, not a loop, but "just" a code. However, due to the .list key, it becomes a loop. To see that more clearly, consider the MWE

\documentclass{article}
\usepackage{pgfkeys,pgffor} % .list requires pgffor
\begin{document}
\pgfkeys{/student/.cd, % switch to student
hello/.code={hello #1!}}
\pgfkeys{/student/hello=world}

\pgfkeys{/student/hello/.list={world,duck,koala,marmot}}
\end{document}


Here, hello is just a simple code that prints hello <arg>!, where arg is the argument. (If you have a definition inside a definition, you need to increase the number of #, as explained e.g here. This is the reason why there are two # in the definition of \ifdate.)

What is important now is that the .list key makes the code loop over the argument, as can be seen in (the admittedly stupid example) \pgfkeys{/student/hello/.list={world,duck,koala,marmot}}. Note also that .list requires the pgffor library (on top of pgfkeys, which would be sufficient to make the first part of the MWE work).