2

I am doing a wedding invitation and I want the RSVP to have the person's name on it. I also need the name to appear in another, very specific location on the invitation. The invitation only takes up half of a page so I'd like to do two per page. So, I need the second person's name to appear in two different, very specific locations on the page. Then the next page should have the third and fourth people and so on. I have used the textpos package to place figures on the entire invitation and have attempted to get the datatool package to place the names from a .txt file but I have had no luck. Any ideas? This is my insufficient work thus far.

\documentclass[11pt,a4paper]{article}
\usepackage[absolute]{textpos}
\usepackage{datatool}
\DTLloadrawdb{database}{Database.txt}

\usepackage{datatool}

\begin{document}

\DTLforeach{database}{\name=Name}{
\begin{textblock*}{1in}(1in,1in)
\name 
\end{textblock*}
}

\DTLforeach{database}{\name=Name}{
\begin{textblock*}{1in}(2in,1in)
\name 
\end{textblock*}
}

\DTLforeach{database}{\name=Name}{
\begin{textblock*}{1in}(2in,2in)
\name 
\end{textblock*}
}

\DTLforeach{database}{\name=Name}{
\begin{textblock*}{1in}(1in,2in)
\name 
\end{textblock*}
}

\end{document}
  • 2
    Can you show us what you've tried so far? Working from what you already have set up is likely to produce a better solution for you; and people will be more inclined to help out. :-) – Paul Gessler Mar 10 '14 at 20:13
  • Ok, so I can make it place names. I built a text file in csv format with one column called "Name". I added the entries Bob and John. The only thing I can get to work to place names is the simplest possible thing, but that places both names on top of each other. I guess I don't know the datatool package too well. If I try to insert page breaks it doesn't work. I want Bob on the 1 inch line and John on the 2 inch line. Then I want it to page break and add say Steve and Cindy. I'll follow with the MWE that clearly isn't doing it. – ben Mar 10 '14 at 21:30
1

This should do:

\documentclass[11pt,a4paper]{article}
\usepackage[absolute]{textpos}
\usepackage{datatool}
\DTLloadrawdb{database}{Database.txt}
\pagestyle{empty}

\begin{document}

\newcounter{PlaceOnPage}

\DTLforeach{database}{\name=Name}{
    \begin{textblock*}{1in}(1in,1in)
        \name 
    \end{textblock*}
    \begin{textblock*}{1in}(2in,1in)
        \name 
    \end{textblock*}
    \ifcase\value{PlaceOnPage}\relax
        \textblockorigin{0pt}{0.5\paperheight}
        \stepcounter{PlaceOnPage}
    \or
        \null\clearpage
        \textblockorigin{0pt}{0pt}
        \setcounter{PlaceOnPage}{0}
    \fi
}

\end{document}

To have more than two names on each page, you can expand the \ifcase-construct to like below, and perhaps add \usepackage[landscape]{geometry} to the preamble.

\ifcase\value{PlaceOnPage}\relax
    \textblockorigin{0pt}{0.5\paperheight}
    \stepcounter{PlaceOnPage}
\or
    \textblockorigin{0.5\paperwidth}{0pt}
    \stepcounter{PlaceOnPage}
\or
    \textblockorigin{0.5\paperwidth}{0.5\paperheight}
    \stepcounter{PlaceOnPage}
\or
    \null\clearpage
    \textblockorigin{0pt}{0pt}
    \setcounter{PlaceOnPage}{0}
\fi
  • So I ran this and it generated the first name, Bob, four times. I want something that will generate Bob only on the top lines, then the next name. I then want it to page break and generate the third and fourth names, then on the next page the fifth and sixth. – ben Mar 11 '14 at 0:47
  • I've edited the answer, does it produce the desired result now? – Jonas Granholm Mar 11 '14 at 0:56
  • Just for curiosity's sake. How would you make it do four different names per page? – ben Mar 13 '14 at 14:14
  • See updated answer :) – Jonas Granholm Mar 14 '14 at 0:52

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.