[Tex/LaTex] A package to make stickers

packages

I would like to make stickers for envelopes. Each sticker would contain data about one recipient of the letter. I would like to be able to have this data in some text format (CSV) and that LaTeX would take it and format it for printing, of multiple stickers on one page. Is there a package for something like this? Is there some other efficient way to do it?

Best Answer

The envlab package is perhaps the best choice for labels themselves. In combination with datatool this can be very powerful. I've written a demo on this for the UK-TUG pages: summarising here, the LaTeX file is

\documentclass[12pt,a4paper]{letter}
\usepackage[T1]{fontenc}
\usepackage[english,UKenglish]{babel}
\usepackage{lmodern}
\usepackage{datatool}
\usepackage[nocapaddress]{envlab}
\DTLloaddb{mailing-list}{example.csv}
\SetLabel 
  {63.5mm}  % width
  {38.1mm}  % height
  {15.15mm} % top margin
  {7.75mm}  % left margin
  {2mm}     % inter-label gap
  {3}       % columns
  {7}       % rows
\makelabels % Tell envlab to make labels in the document.
\makeatletter % We need to access some internal commands
\newcommand*{\IfDataT}[1]{% Create a macro taking one argument
  \ifx#1\empty
    \expandafter\@gobble % Empty input: ignore the next thing
  \else
    \ifx#1\DTLstringnull
      \expandafter\expandafter\expandafter
        \@gobble % NULL input: ignore the next thing
    \else
      \expandafter\expandafter\expandafter
        \@firstofone % Use the next thing unchanged
    \fi
  \fi
} 
\newcommand*{\IfDataTF}[1]{% Create a macro taking one argument
  \ifx#1\empty
    \expandafter\@secondoftwo % Empty value: use the False branch
  \else
    \ifx#1\DTLstringnull
      \expandafter\expandafter\expandafter
        \@secondoftwo % NULL value: use the False branch
    \else
      \expandafter\expandafter\expandafter
        \@firstoftwo % A real value: use the True branch
    \fi
  \fi
} 
\makeatother

\begin{document}

\startlabels
\DTLforeach{mailing-list}{%
  \title=Title,%
  \firstname=Firstname,%
  \lastname=Surname,%
  \addressI=AddressI,%
  \addressII=AddressII,%
  \addressIII=AddressIII,%
  \town=Town,%
  \postcode=Postcode,%
  \country=Country%
}{%
  \mlabel{}{%
    \title\IfDataT\title{~}\firstname\unskip\ \lastname\\
    \addressI \\ 
    \addressII \IfDataT\addressII\\
    \addressIII \IfDataT\addressIII\\
    \IfDataTF\country{%
      \postcode \IfDataT\postcode{~}\town\\
      \country
    }{%
      \town \\
      \postcode \\        
    }%
  }%
} %
\end{document}

with a database such as

Title,Firstname,Surname,AddressI,AddressII,AddressIII,Town,Postcode,Country,Email
Miss,Alison,Smith,1 The Street,,,SomeTown,AB1 2XY,,smitha@some.com
Mr,Ben,Jones,2 The Close,SmallVillage,,OtherTown,AB2 4XY,,Ben_Jones@email247.org
Mr,Chris,Brown,Housename,The Main Street,OddVillage,BigTown,AB3 6XY,,rt543syt@univ.ac.uk
Dr,From,Abroad,456 Foreign Stra{\ss}e,Place-en-Conti\'nent,,Townii,2341R,NotInUK,f.abroad@some.place.else

The code I've added on top of the basics here is used to 'pretty print' addresses: you might not need all of it.

Related Question