1

I need to loop a list of names in a CSV file, and for each new name (row), create a page using a background "front" and add the name in the right side, say ~75% from left.

Then create a new page, with just the background "back" since we would print as double-sided paper.

Here's what I have so far, except from 3rd page onwards, it seems to merge both front and back backgrounds onto the same page.

\documentclass[12pt, a5paper,landscape]{memoir} % Use memoir for vplace

\usepackage[utf8]{inputenc} % required for characters like: Î ç etc.
\usepackage{color}
\usepackage{wallpaper} % For background image frame
\usepackage{datatool} % For loading data from file (e.g. from csv)

% Load database 'names' from file 'namelist.csv'
\DTLloaddb[keys={OrderNumber,Date,First,Last,Email,Quantity,Ticket,Order,Total,Fees,Payment,Status,Country,DrupalOrg,Meal,OtherMeal,Job,Company}]{names}{namelist.csv}

\begin{document}
  \color{white}
  \pagestyle{empty}

  % For each record (line) in database 'names'
  \DTLforeach{names}
  {\firstname=First, \lastname=Last}{
    {
      \TileWallPaper{\paperwidth}{\paperheight}{A5_Badge_Front_Without_Placeholder}
      \begin{vplace}[1.4]
        \raggedleft{\bfseries\MakeUppercase{\firstname}} {\bfseries\MakeUppercase{\lastname}}
      \end{vplace}
      \vspace{\fill}
      \leavevmode\thispagestyle{empty}\newpage
      \clearpage
    }
    {
      \TileWallPaper{\paperwidth}{\paperheight}{A5_badge_back}
      \vspace{\fill}
      \leavevmode\thispagestyle{empty}\newpage
      \clearpage
      \newpage
      \cleardoublepage
    }
}

\end{document}

See result at: https://www.sharelatex.com/project/58a1eb8f4cd29cd31efc3897

Reading from CSV works fine, adding a background - for just say front and outputting - was working fine before but I needed to add the new 2nd page in-between for the 'back' background. I tried adding \vspace{\fill} around and using different variations of \clearpage vs \newpage but still get weird output for 3rd page (5th page etc.).

2 Answers 2

1

Here is a solution that should do what you need. The changes:

  • \pagestyle{empty} in the preamble saves you from \thispagestyle{empty} on every page.

  • As you already discovered, you have to use \ThisTileWallPaper instead of \TileWallPaper.

  • Put the name into a box of width zero, centered. After that you have only to position this center, e.g. with \hspace*, and the name will extend to both sides symmetrically.

    \hspace*{12.1cm}\makebox[0pt]{First Name Second Name}
    
  • To position the name vertically, add \vspace*{3cm} above.

.

\documentclass[12pt,a5paper,landscape]{memoir} % Use memoir for vplace
\usepackage[utf8]{inputenc} % required for characters like: Î ç etc.
\usepackage{color}
\usepackage{wallpaper} % For background image frame
\usepackage{datatool} % For loading data from file (e.g. from csv)

% Load database 'names' from file 'namelist.csv'
\DTLloaddb[keys={OrderNumber,Date,First,Last,Email,Quantity,Ticket,Order,Total,Fees,Payment,Status,Country,DrupalOrg,Meal,OtherMeal,Job,Company}]{names}{namelist.csv}
\pagestyle{empty}
\begin{document}
  \color{white}

  % For each record (line) in database 'names'
  \DTLforeach{names}
  {\firstname=First, \lastname=Last}%
  {\ThisTileWallPaper{\paperwidth}{\paperheight}{A5_Badge_Front_Without_Placeholder}%
   \vspace*{3cm}
   \hspace*{12.1cm}\makebox[0pt]{%
     \begin{tabular}{c}
     \bfseries\MakeUppercase{\firstname} \MakeUppercase{\lastname}\\[3mm]
     Some more stuff\\[3mm]
     Even more of it
     \end{tabular}%
   }
   \clearpage
   \ThisTileWallPaper{\paperwidth}{\paperheight}{A5_badge_back}%
   \mbox{}\clearpage
  }


\end{document}
4
  • Ah that works well - I had tested vpace but now with the * character. Thanks a lot @gernot !
    – dan2k3k4
    Commented Feb 13, 2017 at 22:28
  • @dan2k3k4 You are welcome. Good luck with the event. Sounds interesting, in a great surrounding.
    – gernot
    Commented Feb 13, 2017 at 22:37
  • Thanks :) mmm what if I want to add new lines of text ? something like: \vspace*{\fill} then \hspace*{12.1cm}\makebox[0pt]{\bfseries\MakeUppercase{\newtext}} doesn't really allow for actual vertical position? but I guess I just do it without \fill
    – dan2k3k4
    Commented Feb 13, 2017 at 22:39
  • 1
    @dan2k3k4 I have modified the solution a bit, with a suggestion how to add more stuff.
    – gernot
    Commented Feb 13, 2017 at 22:46
0

Ah ok I seem to have found out I needed to use \ThisTileWallPaper and not \TileWallPaper - now I just need to correctly position the text to be 'centered' around the 75% mark (from far left being 0%... 50% being default center... etc.) \raggedleft doesn't really fix that problem for me but it helps for now.

\documentclass[12pt, a5paper,landscape,twoside]{memoir} % Use memoir for vplace

\setlength{\pdfpagewidth}{\paperwidth}
\setlength{\pdfpageheight}{\paperheight}

\usepackage[utf8]{inputenc} % required for characters like: Î ç etc.
\usepackage{color}
\usepackage{wallpaper} % For background image frame
\usepackage{datatool} % For loading data from file (e.g. from csv)

% Load database 'names' from file 'namelist.csv'
\DTLloaddb[keys={OrderNumber,Date,First,Last,Email,Quantity,Ticket,Order,Total,Fees,Payment,Status,Country,DrupalOrg,Meal,OtherMeal,Job,Company}]{names}{namelist.csv}

\begin{document}
  \color{white}
  \pagestyle{empty}
  % For each record (line) in database 'names'
  \DTLforeach{names}{\firstname=First, \lastname=Last}{
    {
      \ThisTileWallPaper{\pdfpagewidth}{\pdfpageheight}{A5_Badge_Front_Without_Placeholder}
      \begin{vplace}[1.4]
        \raggedleft{\bfseries\MakeUppercase{\firstname}} {\bfseries\MakeUppercase{\lastname}}
      \end{vplace}
      \clearpage
    }
    {
      \ThisTileWallPaper{\pdfpagewidth}{\pdfpageheight}{A5_badge_back}
      \clearpage\mbox{}\clearpage
    }
}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .