Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

We are organizing an event. There will be around 60 participants and I need to prepare name badges (tags) for them.

The badge will involve, name surname and affiliation fields which is different for each participant.

These fields are already in an Excel sheet actually. So, I can easily export them to a csv file.

And there will be a footer with a logo (picture) and the name of the organization.

I want to create a PDF holding 8 or 10 cards per page and then cut with scissors.

I can create the file manually in Word but I don't like to. How can I automate this process in LaTeX?

As an example, here's a simple design that I would like to have:

enter image description here

share|improve this question
    
I use datatool.sty to this. –  Sigur Jan 20 '13 at 14:37
    
I have seen a solution with a Visual Basic macro in Excel that generated the namecards on new worksheets. –  marczellm Jan 20 '13 at 16:10
add comment

4 Answers

Here's a simple solution using pstricks

\documentclass{article}
\usepackage{pstricks}%..% to create card and position tags/labels
\usepackage{graphicx}%..% for loading and working with the logo
\usepackage{datatool}%..% for managing source for names and affiliations
\usepackage[margin=0.5in]{geometry}
%% command to handle the event name and related matter.
\newcommand{\eventname}{\begin{minipage}[c]{2.5in}\raggedright{}%
                            Name of Event \\ 
                            Sponsored by Various and Sundry
                        \end{minipage}}
%% in case you want some white space for when cutting the cards:  otherwise set both to zero.
\newlength{\cardhsep}\setlength{\cardhsep}{2pt}%..% horizontal space between cards
\newlength{\cardvsep}\setlength{\cardvsep}{2pt}%..% vertical space between rows of cards
\newcounter{cntnamecard}                       %..% counter to keep track of namecard and facilitate making "paragraphs"
\psset{unit=0.25in}                            %..% or you can set "xunit=..." and "yunit=..." change dimensions of card
\newcommand{\namecard}[3]{%
    \begin{pspicture}(0,0)(14,8)
        \rput(7,6){\Large{}\textbf{\sffamily{}#1}}%..% node for name
        \rput(7,5){#2}                            %..% node for affiliation
        \psline(0.25,1.75)(13.75,1.75)
        \rput[l](0.25,1){#3}                      %..% node for event name
        \rput[r](13.75,1){\includegraphics[height=0.33in]{example-image-a}}%..% logo
        \pspolygon(0,0)(14,0)(14,8)(0,8)
    \end{pspicture}\hspace*{\cardhsep}%
    \ifodd\thecntnamecard\par\fi%..% automate when "paragraphs" are set.
    \stepcounter{cntnamecard}}
%%
\setlength{\parindent}{0pt}%..% no need for indentation.
\setlength{\parskip}{\dimexpr-\lineskip+\cardvsep\relax}
\renewcommand{\thepage}{}
\begin{document}

\DTLloaddb{namecard}{data.csv}
\DTLforeach{namecard}{\firstname=first,
                      \lastname=last,
                      \school=affiliation,
                      \characterization=characterization}
    {\namecard{\firstname{} \lastname}
              {\school}
              {\eventname}}

\end{document}

where the cvs file looks something like:

"first","last","affiliation","characterization"
  "Bilbo","Baggins","Hobbit U.","Lover of Adventure"
  "Charles","Dickens","Victorian U.","Serial Author"
  "Galileo","Galilei","U. of Pisa","Science Guru"
  "Bruce","Wayne","University of Gotham","Comic Hero"

enter image description here

share|improve this answer
    
It would be nice to have some empty spaces around the borders, to help cutting it. –  Sigur Jan 20 '13 at 16:58
    
+1 Really a nice pstricks hack. –  petrichor Jan 20 '13 at 17:20
add comment
up vote 6 down vote accepted

ticket package fits very well for this use. The pin example is what you seek for:

%%%%
%
% ticket.sty example file for a pin for conferences
%
%%%%
% use the corresponding paper size for your ticket definition
\documentclass[a4paper,10pt]{letter}

% load ticket.sty with the appropriate ticket definition
\usepackage[freepin,crossmark]{ticket}

% load misc stuff
\usepackage{graphicx}

% make your default ticket. \ticketdefault is somewhat like a background
\renewcommand{\ticketdefault}{%
  \put(50,  3){\includegraphics[width=15mm]{ifmlogoc}}
  \put( 5, 13){\line(1,0){60}}
  \put( 7, 10){\scriptsize Animal annual meeting (AAM)}
  \put( 7,  7){\scriptsize In the gardens}
  \put( 7,  4){\scriptsize April 1, 2000}
}

% now what do you like to put in your ticket
\newcommand{\confpin}[2]{\ticket{%
    \put(35,36){\makebox[0mm]{\bfseries\Large #1}}
    \put(35,28){\makebox[0mm]{\bfseries\large #2}}%
}}


%% the pins for the partipiciants ... ;-)
%% you can generate this part from a database!
\begin{document}
\sffamily
\confpin{Camelus dromedarius}{North Africa}
\confpin{Urocyon cinereoargenteus}{America}
\confpin{Galago moholi}{South Africa}
\confpin{Dasypus novemcintus}{South America}
\confpin{Rhinocerus sondaicus}{Java}
\confpin{Canis lupus}{Northern sphere}
\confpin{Ramphastus spec.}{South Amerika}
\confpin{Panthera tigris sondaica}{Java}
\confpin{Hippocampus spec.}{the ocean}
\confpin{Anthonomus grandis}{Mexico}
\confpin{Petrogale penicillata}{Australia}
\confpin{Tarsius spec.}{Sumatra}
\end{document}

The result is as follows:

enter image description here

For boxed badges, use

\usepackage[freepin,boxed]{ticket}

in the preamble. For the other options, see the manual.

To create confpin content, you can use the following command in Excel and copy the content to your document. It assumes that column A has name surname, and column B has affiliation.

=CONCATENATE("\confpin{"; A2; "}{";B2; "}")
share|improve this answer
    
I met this package while looking for a solution and really liked it. So, I decided to put it here as an answer to my own question. –  petrichor Jan 20 '13 at 17:09
add comment

A slight variation from Sigur's answer, building on his code:

\documentclass{article}
\usepackage{pdfpages}
\usepackage[a4paper,margin=.5in]{geometry}
\usepackage{filecontents}
\begin{filecontents*}{informations.csv}
name,sirname,university
Jon,Doe,From Moon
Jane,Dipp,From Mars
Jon,Doe,From Moon
Jane,Dipp,From Mars
Jon,Doe,From Moon
Jane,Dipp,From Mars
Jon,Doe,From Moon
Jane,Dipp,From Mars
Jon,Doe,From Moon
Jane,Dipp,From Mars
\end{filecontents*}
\begin{filecontents*}{cards.tex}
\documentclass[12pt,a5paper,landscape]{article}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{datatool}
\usepackage[lmargin=1cm,tmargin=1cm,bmargin=1.6cm,rmargin=1.6cm]{geometry}
\usepackage{fancybox} % border page and boxes
\usepackage{mathpazo}
\sloppy
\pagestyle{empty}
\fancypage{\setlength{\fboxsep}{8pt}\doublebox}{}
\newcommand{\event}{Univeristy Name \\
University Address - 1\\
University Address - 2}

\begin{document}

\DTLloaddb{list}{informations.csv}

\DTLforeach{list}{%
\firstname=name,\sirname=sirname,\university=university}{%
\fontfamily{pbk}\fontseries{m}\fontshape{n}\selectfont  
\baselineskip 2.5em
\vspace*{2cm} 
\begin{center}
{\Large \firstname~\MakeUppercase{\sirname}}
\vskip 2cm 
{\large \university}
\vfill 

\hrulefill

\parbox[b]{.7\textwidth}{\event}\hfill\fbox{\includegraphics[width=2cm]{example-image-a}}
\end{center}
\newpage
}%
\end{document}
\end{filecontents*}
%
% compile with pdflatex
\immediate\write18{pdflatex cards.tex}
%
\begin{document}
\includepdf[pages=-,nup=2x4,delta=0.0in 0cm,turn=true,frame=true]{cards.pdf}
\end{document}

enter image description here

share|improve this answer
    
Please, how to use your code? Should I save it on a tex file? What to do with \immediate\write18{pdflatex cards.tex}? –  Sigur Jan 20 '13 at 16:15
    
@Sigur Just save the code as somefile.tex and pdflatex somefile.tex. –  Harish Kumar Jan 20 '13 at 16:17
    
I got ! Package pdfpages Error: Cannot find file cards.pdf'.` –  Sigur Jan 20 '13 at 16:30
    
@Sigur cards.pdf will be created in the same folder (unless you have some mechanism to move it elsewhere) as the somefile.tex. Just look at it. –  Harish Kumar Jan 20 '13 at 16:32
    
Sorry, I didn't note the \inclugraphics. I have to change it. –  Sigur Jan 20 '13 at 16:41
add comment

Here are a simple example. Please, adapt it to your case.

The file informations.csv (the first line is for variable names)

"name","sirname","university"
"Aaaa","Bbbb","Cccc"

The file foo.tex (format according to your preferences)

\documentclass[12pt,a5paper,landscape]{article}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% If the error
% ``No room for ..''
% increase the reserved inserts
%--------------------------------------------
% \usepackage{etex} % to use etex extensions 
% \reserveinserts{28} % using etex extensions

\usepackage[english]{babel}

% UTF-8 support any characters
\usepackage[utf8]{inputenc}
%\usepackage[T1]{fontenc}
%\usepackage{ucs}
% Defaul loaded character table is ASCII and latin

\usepackage{amsmath}
\usepackage{amssymb} % amsfonts is part of amssymb

\usepackage{graphicx}
\usepackage[usenames]{color}
%\usepackage{chancery} % change serif to Zapf Chancery
\usepackage{datatool}
\usepackage[lmargin=1cm,tmargin=1cm,bmargin=1.6cm,rmargin=1.6cm]{geometry}
\usepackage{fancybox} % border page and boxes
\usepackage{mathpazo}

\sloppy

\pagestyle{empty}

% box around pages, using fancybox package
%
% \fancypage{\fbox}{}
% \fancypage{\setlength{\fboxsep}{8pt}\setlength{\shadowsize}{8pt}\shadowbox}{}


%\fancypage{\setlength{\fboxsep}{8pt}\shadowbox}{}
\fancypage{\setlength{\fboxsep}{8pt}\doublebox}{}

\newcommand{\event}{Insert the title of event here}

\begin{document}
% default separator is coma and default delimiter is double quote      
% \DTLsetseparator{,}
% \DTLsetdelimiter{"}

\DTLloaddb{list}{informations.csv}

\DTLforeach{list}{%
\firstname=name,\sirname=sirname,\university=university}{%

\fontfamily{pbk}\fontseries{m}\fontshape{n}\selectfont  
\baselineskip 2.5em

\vspace*{2cm} 

\begin{center}
{\Large \firstname~\MakeUppercase{\sirname}}

\vskip 2cm 

{\large \university}

\vfill 

\hrulefill

\event~\fbox{logo here}
\end{center}

\newpage
}  
\end{document}

Here is the output: enter image description here

share|improve this answer
    
I created a file with the content wou gave but I got many errors: Missing \endcsname inserted: \DTLloaddb{list}{informations.csv}", Missing { inserted: \DTLloaddb{list}{informations.csv}, Package datatool Error: Can't assign \firstname : there is no key name' in data base list': }. –  petrichor Jan 20 '13 at 15:49
    
And actually I would like to get many badges in an A4 page. Not getting a badge per page. –  petrichor Jan 20 '13 at 15:50
    
I believe that the easiest way is to print more than one page, changing the printer options. My sample create one page for each line on csv file. You can change the page size using geometry (see the code) and then you print 4 or 8 pages per sheet. –  Sigur Jan 20 '13 at 15:52
    
Your csv file looks like mine? Does it have the same variables defined? Did you save it on the same folder as your tex file? –  Sigur Jan 20 '13 at 15:55
    
Yes, I've created it in the same folder with the same name and content. –  petrichor Jan 20 '13 at 16:00
show 2 more comments

Your Answer

 
discard

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.