TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using datatool to load a csv table. Students names are in that table (first column first name, second column last name) and I like to print them on the exam. In a related question, I asked how to print a student id number on each exam. In a similar way I like to print the names taken from the table on each exam. My first approach (I just like to print an arbitrary value) looks like this and unfortunately doesn't work:






\newcommand{\studentname}[2]{#1 #2}



\multido{\nx = 1+1}{3}{  
  % Uncomment next lines if exam has an odd number of pages.
%   \newpage
%   \mbox{}
%   \newpage


So how can I achieve that the table is iterated within multido? And I need some kind of macro that I can use in examMain.tex to access the students full name?

A possible example of members.cvs could look like this

Name1, FirstName1
Name2, FirstName2
Name3, FirstName3
share|improve this question
Could you please add a small example of how the members.csv file is organized? – egreg Feb 12 '13 at 11:57
I added an example. But I think that doesn't really matter. I suggest a situation where I already had been able to seperate my file with the help of datatool into 2 columns, one for the family name and one for the first name. – DaPhil Feb 13 '13 at 11:32
up vote 3 down vote accepted

Use \DTLforeach:


\noindent Student ID = \fbox{\studentid}\quad
\studentfirstname\ \studentlastname


Solve the equation $x-1=0$.



  \ifnum\thestudentidcounter<10 0\fi



   \par\bigskip\hrule\bigskip % just not to produce many pages


enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.