# How to batch generate badges with a list of names?

I want to make a number of badges using LaTeX for the participants of a summer school. There are 40 or so people, so I don't want to manually change the name and compile and then print. I could think of:

1. Making a single document with a dropdown box with 40 choices. I don't know if it is possible to automate the choosing and printing in this case.

2. Using a script language such as python to call latex to do the job. But I have 0 experience with Python, and I didn't find a foolproof tutorial on the web (probably because of wrong search keywords).

So...I'm waiting for you guys to come up with a good solution :-).

-
You should search this side for "serial letter". This will give you some examples on how people are getting data from .csv and producing mutliple pdfs from it. –  LaRiFaRi Jul 11 at 12:40
Probably datatool package provides some help –  Christian Hupfer Jul 11 at 12:49
There's also csvsimple, which would surely be enough for this kind of task. Would take the fun out of the answer below, however.... –  jon Jul 11 at 13:43
–  Mike Renfro Jul 11 at 14:49

\documentclass{article}

\begin{document}

\makeatletter
\def\Name{\expandafter\@firstoftwo\name}
\def\Affiliation{\expandafter\@secondoftwo\name}
\setlength\fboxsep{10pt}

\@for \name:=%
{{David}{here}},%
{{Paulo}{There}},%
{{egreg}{Somewhere}},%
{{Werner}{Not Here}},%
{{Gonzalo}{Not There}}%
\do {
\clearpage
\fbox{\begin{minipage}[c][4cm]{6cm}
Name: \Name\\
Afilliation: \Affiliation
\end{minipage}}}

\end{document}

-
Thank you. It is a good start. Is there an \affiliation too?I tried but failed. –  Troy Woo Jul 11 at 13:21
@user74973 updated with two fields per name, more could be added as an exercise:-) –  David Carlisle Jul 11 at 13:28
Wow,I really need to learn such techniques...is it something written in the texbook? –  Troy Woo Jul 11 at 13:30
@user74973 \@for \@firstoftwo are defined in the latex format (so not in the texbook) The texbook of course describes the primitoves that define those commands. –  David Carlisle Jul 11 at 13:32