[OS X TeX] creating a "smart macro"

Alan Munn amunn at msu.edu
Wed Apr 22 15:08:06 CEST 2009

At 10:58 AM +0200 4/22/09, Alex Hamann wrote:
>Hi,
>
>I need to create a number of name tags for a class. The idea is to
>create a list of the students' names and have a macro that will
>fetch the first name, then reexecute using the second name and so on.
>This is the layout I created. Can anybody give me a hint how to make
>a smart macro out of this that will work its way through a list of
>109 students and create a pdf in which every single page looks like
>the output of the code below while replacing \1stname and \lastname
>with the names in the list?
>
>TIA,
>Alex
>
>\documentclass[landscape,a5paper,pagesize,DiV=14]{scrartcl}
>\usepackage{xltxtra}
>\setmainfont[Mapping=tex-text]{Hoefler Text}
>\pagestyle{empty}
>\usepackage{fix-cm}
>\begin{document}
>\vspace*{7,5cm}
>\center
>\huge{\1stname}\\
>\fontsize{60}{70}\selectfont
>  \textbf{\lastname}
>\vspace*{-1cm}
>\pagebreak
>
>\end{document}

Use the datatool package.  Store your names in an Excel or OpenOffice
csv file and then read the data in.

is called students.csv the following will do the trick. (You might
want to make the first name a bit bigger, though...)  -Alan

\documentclass[landscape,a5paper,pagesize,DiV=14]{scrartcl}
\usepackage{xltxtra}
\setmainfont[Mapping=tex-text]{Hoefler Text}
\pagestyle{empty}
\usepackage{fix-cm}
\usepackage{datatool}
\begin{document}
\DTLforeach{students}{%
\firstname=FirstName,\lastname=LastName}{%
\vspace*{7,5cm}
\center
\huge{\firstname}\\
\fontsize{60}{70}\selectfont
\textbf{\lastname}
\vspace*{-1cm}
\pagebreak
}
\end{document}
--
Alan Munn						amunn at msu.edu
Department of Linguistics
and Germanic, Slavic, Asian and African Languages		Tel.
517-355-7491
Michigan State University, East Lansing MI 48824 USA	Fax	517-432-2736