I am trying to create a LaTex document that will allow me to write the text of the birthday invitations once with the formatting I desire, and then have Latex automatically fill in the recipient's names from a list on each different one (as well as have multiple invitations per letter sized sheet of paper).

I have searched this sight as well as the Latex wikibook and a Latex website for templates (to see if anyone has done something similar) or similar concepts. I haven't found anything that would help me do this.


I would suggest using a two-step approach:

  1. Create a standard document layout that has the outline for the invitation set according to your requirements.
  2. Use pdftk or pdfpages (or something similar) to print the output in 2-up, 4-up, or whatever.

Regarding 1, here's a template:

enter image description here

\usepackage[paperwidth=4in,paperheight=5.5in,margin=.5in]{geometry}% http://ctan.org/pkg/geometry
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\pagestyle{empty}% No page headers/footers
\setlength{\parindent}{0pt}% No paragraph indent
    Dear ##1,\par\medskip
    See you there,\par\medskip
    \textit{Random Randolfsky}

geometry sets the document layout and size, while lipsum provided some dummy text. etoolbox provides the list-processing capability via \docsvlist{<list of names>}. The main function is \do which processes each element of the comma separated list. I've renewed it to print some salutation, followed by the invitation, followed by the signature.

Since \clearpage only clears the page if it is non-empty, there is no concern issuing it at the start of \do.

  • 21
    oh, please use ragged right! this is a party, not a solemn symposium. – barbara beeton Jun 22 '12 at 22:14
  • 1
    I have tried your solution. Thank you for the suggestion. The example was very helpful. I had trouble getting lipsum to work, but since I didn't need that to test the automatic names I went ahead and replaced it with actual text. It does automatically put names into the invites from a comma seperated list like I was wanting. =) Thank you! – Marie Mikels Jun 24 '12 at 23:33
  • @MarieMikels: Exactly. lipsum is merely used to populate a document with dummy text and is not needed for the "end product". Consider using @_barbarabeeton's suggestion of \raggedright, just for fun. Also, if this answer helped you most, consider accepting it as such. See How do you accept an answer? – Werner Jun 25 '12 at 0:38
  • 2
    Instead of \raggedright you should use the ragged2e package and \RaggedRight. Standard \raggedright looks awful. – Christian Jun 25 '12 at 6:20

Here is a solution using a csv data file with the names, then using the datatool package to create the invitations, finally using Werner's recommandation to use a pdf printer to get 4up. I used PDF995 (which was on my laptop).

First create the csv file. I just used notepad to create the file and then did a save as to marie-names.txt

I now have the following file in csv format

Bob the Tomatoe
Larry the Cucumber
Big Bird
Waldo (if found) 

Now I modified the instructions found at http://latex-my.blogspot.com/2012/01/mail-merge-batch-generating-documents.html to get the following MWE. Note: old-border.jpg is from http://www.fromoldbooks.org/Aubrey-HistoryOfEngland-Vol2/pages/438-Border-of-twigs/ and picture1.png was converted using powerpoint from http://aknockoutphoto.wordpress.com.

% Use scrartcl to allow larger base font size

\usepackage{wallpaper} % For background image frame

% Load database 'names' from file 'marie-names.txt''
\DTLloaddb{firstnames}{marie-names.txt}%Import the txt file in csv format as a database
\linespread{2}\selectfont %Changing linespacing for the font and enabling the change
\pagestyle{empty}% Turn of page numbers
% Set old-border.jpg as background image
\TileWallPaper{\paperwidth}{\paperheight}{old-border}%Loading a borderpattern
% Ref: http://www.fromoldbooks.org/Aubrey-HistoryOfEngland-Vol2/pages/438-Border-of-twigs/

% For each record (line) in database 'names'
% Assign field values by name to macros
    {\LARGE\bfseries Birthday Party Invitation}\par
   \smallskip\large Dear \name,\par\smallskip
   You are invited to a cookout to celebrate Cookie Monster's 44th birthday!\par
    Saturday, November 10, 2012 from 5:30 -- 9:00 p.m.\par 
    1234 Sesame Street\par 
    Anywhere, USA\par 
  Please RSVP to Miss Piggy at 987-654-abcd\par \bigskip


Now compile with pdflatex and view. Now print with a package capable of creating a 4up pdf page and your get

enter image description here


Create a txt file consisting of rows of the following form:


You can use up to 9 fields (because commands can't have more parameters in LaTeX). All entries must have the same number of fields.
Save this file e.g. as adr.txt
Then write your letter with latex and use:

   \begin{letter}{#1 #2 \\#4\\#5}
   \opening{Dear #1,} 
   We would like to invite you ...

All you have to do is to replace names, given names, street etc. with the field number of your \ADR definition. This should work on all letter classes.

  • I just edited the code to make a MWE. Very nice idea. – R. Schumacher Jun 25 '12 at 14:33
  • @R.Schumacher I use the way of may edited answer. Each begin{letter} starts a new page, though no \clearpage is needed. – Peter Breitfeld Jun 26 '12 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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