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.

I have a a document that is making me sheets of cards. A stripped down, almost minimal example looks something like

\documentclass{article}
\usepackage[utf8]{inputenc} %Needed for input
\usepackage{venturis} %CM does not look right at this size
\usepackage[T1]{fontenc} %Needed for output
\usepackage[margin=0.4cm]{geometry} %The layout gets screwed up if I don't include this.

\newlength\cardheight
\newlength\cardwidth
\setlength\cardheight{0.3\textheight}
\setlength\cardwidth{0.3\textwidth}

\setlength{\fboxsep}{20pt}

\newcommand\card[2]{%
\begingroup\fboxsep=10pt%
\fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax}%
\raggedright%
\vspace{0.5 \baselineskip}%
\LARGE #1%
\vfill%
\noindent \normalsize #2%
\end{minipage}}%
\hspace{1pt}%
\endgroup}%

\makeatletter%
 \newcommand{\cards}[2]{%
 \@for\@c:=#1\do{%
  \card{\@c}{#2}%
 }%
 }%
\makeatother%

\newcommand{\blank}{\hrulefill}

\pagestyle{empty}

\begin{document}
\centering

\cards{%Basic set
A big hoopla about nothing,%
A wheelchair death race%
}{Cards Against Humanity: Googling this is probably a bad idea}%
\cards{%The Canadian Expansion
Burning down the White House,%
Terry Fox's prosthetic leg,%
{The Offical Languages Act \\\vspace{\baselineskip} \noindent La Loi sur les langues officielles.},%To show you some of my cards are a bit more complex
The Front de Libération du Québec,%
Poutine,%
Killing a Moose with your bare hands%
}{Cards Against Humanity:\\ The Canadian Expansion. No really, don't google this at work.}%
\cards{%The Second Expansion
A piñata full of scorpions%
}%
{Cards Against Humanity:\\The Second Expansion. This if a card game for horrible people.}%
\end{document}

This works perfectly to lay out the front of the card, as you can see. However, I'd like to have backs on my cards. How would I go about automatically interleaving pages that contains card backs with some text of my choice? That way when I print it on a duplex printer I'll get fronts and backs to my cards.

Edit: To clarify, this is one page of my document. I've got 126 pages in my actual document, with multiple \card commands, one for each set. I don't want to manually have to set up that many backgrounds, so I want one that will automatically place the text "Cards Against Humanity" on the back of each card (ie on every other page, but placed where there is a card, so pages with uneven card numbers still get proper backs.)

share|improve this question
    
At least for the European Formats (well actually DIN A5 to 9) I made an attempt some time ago, see github.com/kellertuer/Kartei to set cards automatically, though that would mean, that you have to adapt your 126 (or 63?) cards with respect to their code. The manual is still only available in german, though. –  Ronny Dec 12 '13 at 7:40
add comment

2 Answers

The following interface collects card backs in a list macro and then processes it once you have a collection of 9 or when you're \AtDocumentEnd:

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc} %Needed for input
\usepackage{venturis} %CM does not look right at this size
\usepackage[T1]{fontenc} %Needed for output
\usepackage[margin=0.4cm]{geometry} %The layout gets screwed up if I don't include this.
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox (for list processing)

\newlength\cardheight\setlength\cardheight{0.3\textheight}
\newlength\cardwidth\setlength\cardwidth{0.3\textwidth}
\newcounter{itemcnt}
\newcommand{\cardbacks}{}% List of card backs

\setlength{\fboxsep}{20pt}

\makeatletter
% http://tex.stackexchange.com/q/308/5764
\def\ifemptyarg#1{%
  \if\relax\detokenize{#1}\relax % H. Oberdiek
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}
\makeatother

\newcommand{\setcardcontent}[2]{{%
  \setlength{\fboxsep}{10pt}%
  \fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax}%
    \raggedright%
    \vspace{0.5 \baselineskip}%
    \LARGE #1%
    \vfill%
    \noindent \normalsize #2%
  \end{minipage}}%
  \hspace{1pt}%
}}

\newcommand{\card}[3][Cards Against Humanity]{%
  \ifemptyarg{#1}{}{\stepcounter{itemcnt}}% Another card has been added
  \ifnum\value{itemcnt}>9\relax
    \clearpage
    \renewcommand*{\do}[1]{\setcardcontent{}{##1}}%
    \dolistcsloop{cardbacks}% Set card backs
    \renewcommand{\cardbacks}{}% Clear list
    \clearpage
    \setcounter{itemcnt}{1}% Restart counting cards
  \fi%
  \ifemptyarg{#1}{}{\listgadd{\cardbacks}{#1}}%
  \setcardcontent{#2}{#3}%
}%

\makeatletter%
\newcommand{\cards}[3][Cards Against Humanity]{%
  \@for\@c:=#2\do{%
    \card[#1]{\@c}{#3}%
  }%
}%
\makeatother%

\AtEndDocument{% Flush remainder of card backs
  \clearpage
  \renewcommand*{\do}[1]{\setcardcontent{}{#1}}%
  \dolistcsloop{cardbacks}% Set card backs
}

\newcommand{\blank}{\hrulefill}

\pagestyle{empty}

\begin{document}
\centering

\cards{%Basic set
  A big hoopla about nothing,%
  A wheelchair death race%
}{Cards Against Humanity: Googling this is probably a bad idea}%
\cards{%The Canadian Expansion
  Burning down the White House,%
  Terry Fox's prosthetic leg,%
 {The Offical Languages Act \\\vspace{\baselineskip}
  \noindent La Loi sur les langues officielles.},%To show you some of my cards are a bit more complex
  The Front de Libération du Québec,%
  Poutine,%
  Killing a Moose with your bare hands%
}{Cards Against Humanity:\par The Canadian Expansion. No really, don't Google this at work.}%
\cards{%The Second Expansion
  A piñata full of scorpions%
}{Cards Against Humanity:\par The Second Expansion. This if a card game for horrible people.}%

\cards{%The Second Expansion
  A piñata full of scorpions%
}{Cards Against Humanity:\par The Second Expansion. This if a card game for horrible people.}%
\cards{%The Canadian Expansion
  Burning down the White House,%
  Terry Fox's prosthetic leg,%
 {The Offical Languages Act \\\vspace{\baselineskip}
  \noindent La Loi sur les langues officielles.},%To show you some of my cards are a bit more complex
  The Front de Libération du Québec,%
  Poutine,%
  Killing a Moose with your bare hands%
}{Cards Against Humanity:\par The Canadian Expansion. No really, don't Google this at work.}%

\end{document}

The idea is to use \card as the main card-setting macro, with an optional argument that stipulates what should be printed on the back. Some work may still be required to reorder the backs if they are not supplied in groups of three. However, in your case - with all cards having the same back - this should not be a problem.

List gathering and processing is made possible through etoolbox.


Original solution:

I'd use the following definition for \cardback:

\newcommand\cardback[1]{%
  \begingroup\fboxsep=10pt%
    \fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax}%
      \raggedright%
        %\rlap{\raisebox{\dimexpr-\height}[0pt][0pt]{% Underlay image background
          \includegraphics[width=\linewidth,height=\cardheight]{#1}%
        %}%
    \end{minipage}}%
  \hspace{1pt}%
\endgroup}%

It inserts an image to exactly cover the same area as the text. If you wish to overlay it with text as well, uncomment the \rlap{\raisebox...} portion. Then you can add whatever you want since the image will be placed underneath the text. Of course, this requires graphicx. You can extend it the way you want to by means of macros and loops, similar to what you've done for \cards.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc} %Needed for input
\usepackage{venturis} %CM does not look right at this size
\usepackage[T1]{fontenc} %Needed for output
\usepackage[margin=0.4cm]{geometry} %The layout gets screwed up if I don't include this.
\usepackage{graphicx}% For images

\newlength\cardheight
\newlength\cardwidth
\setlength\cardheight{0.3\textheight}
\setlength\cardwidth{0.3\textwidth}

\setlength{\fboxsep}{20pt}

\newcommand\card[2]{%
\begingroup\fboxsep=10pt%
\fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax}%
\raggedright%
\vspace{0.5 \baselineskip}%
\LARGE #1%
\vfill%
\noindent \normalsize #2%
\end{minipage}}%
\hspace{1pt}%
\endgroup}%

\newcommand\cardback[1]{%
  \begingroup\fboxsep=10pt%
    \fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax}%
      \raggedright%
        %\rlap{\raisebox{\dimexpr-\height}[0pt][0pt]{% Underlay image background
          \includegraphics[width=\linewidth,height=\cardheight]{#1}%
        %}%
    \end{minipage}}%
  \hspace{1pt}%
\endgroup}%

\makeatletter%
\newcommand{\cards}[2]{%
 \@for\@c:=#1\do{%
  \card{\@c}{#2}%
 }%
 }%
\makeatother%

\newcommand{\blank}{\hrulefill}

\pagestyle{empty}

\begin{document}
\centering

\cards{%Basic set
A big hoopla about nothing,%
A wheelchair death race%
}{Cards Against Humanity: Googling this is probably a bad idea}%
\cards{%The Canadian Expansion
Burning down the White House,%
Terry Fox's prosthetic leg,%
{The Offical Languages Act \\\vspace{\baselineskip} \noindent La Loi sur les langues officielles.},%To show you some of my cards are a bit more complex
The Front de Libération du Québec,%
Poutine,%
Killing a Moose with your bare hands%
}{Cards Against Humanity:\\ The Canadian Expansion. No really, don't google this at work.}%
\cards{%The Second Expansion
A piñata full of scorpions%
}%
{Cards Against Humanity:\\The Second Expansion. This if a card game for horrible people.}%

\clearpage

\cardback{example-image-a}%
\cardback{example-image-b}%
\cardback{example-image-c}%
\cardback{example-image-c}%
\cardback{example-image-a}%
\cardback{example-image-b}%
\cardback{example-image-b}%
\cardback{example-image-c}%
\cardback{example-image-a}%
\end{document}
share|improve this answer
    
Does it have to be an image? The card back I was thinking of was just text, not an image. –  Canageek Dec 12 '13 at 6:17
    
@Canageek: No, it doesn't have to be an image. I just placed an image to showcase that as a possibility. If you wish to place something on the back that is text, then you can literally just duplicate your front page, no? –  Werner Dec 12 '13 at 6:21
    
I see I didn't explain well; my document is 126 pages long, I want it to automatically interleave card backs for each card. –  Canageek Dec 12 '13 at 6:25
    
@Canageek: I see your updated request... here's a suggestion. How about creating a separate document that does the interleaving via pdfpages? I guess that's always an option. –  Werner Dec 12 '13 at 6:37
    
That works for me, if you write it up as an answer! Except for the final page, which doesn't have all the cards line up properly, but hey, I can just insert some blank ones to fill it out. –  Canageek Dec 12 '13 at 7:39
show 5 more comments

Im a not sure if the document class flashcards will fit your needs, but make pages of fronts and/or backs automatically, and each card is a simple environment like this:

\begin{flashcard}
  {front text}
  back  text
\end{flashcard}

With the headings style you can also include a running footer with the \cardfrontfoot{text} command, as well as set a header for each card as an optional argument of his environment, as showed in the code below.

For setting portrait cards in a 3 x 3 layout, copy the file avery5371.cfg to another file (as mycard.cfg) in the same directory that your document, and edit to modify as desired, for example:

\newcommand{\cardpapermode}{portrait}
\newcommand{\cardpaper}{a4paper}
\newcommand{\cardrows}{3}
\newcommand{\cardcolumns}{3}
\setlength{\cardheight}{9cm}
\setlength{\cardwidth}{6cm}
\setlength{\topoffset}{1cm} 
\setlength{\oddoffset}{1.5cm}
\setlength{\evenoffset}{1.5cm}

Do not copy & paste these commands to the preamble of the main document! They must be in the configuration file and loaded as an option in the document class. That is:

\documentclass[mycard, ...]{flashcards}

A complete example:

\documentclass[mycard,frame]{flashcards}
% Note: mycard.cfg must be in the path 
% Print only fronts = option "fronts"  
% Print only backs = option "backs"  

\usepackage[utf8]{inputenc}
\usepackage{xcolor}

% Card style

\cardfrontheadstyle[\ttfamily]{left} 
\cardfrontfootstyle[\small\itshape]{left}
\cardfrontstyle{headings}


% Macros for simplify 3 back sides. Change as you want 

\newcommand\spade{{\huge $\spadesuit$}\par\bigskip Cards\\ Against\\ Humanity\par\bigskip {\huge $\spadesuit$}}


\newcommand\club{{\huge $\clubsuit$}\par\bigskip Cards\\ Against\\ Humanity\par\bigskip {\huge $\clubsuit$}}


\newcommand\heart{{\color{red}\huge $\heartsuit$}\par\bigskip Cards\\ Against\\ Humanity\par\bigskip{\color{red}\huge $\heartsuit$}}



\begin{document}

\cardfrontfoot{Googling this is probably a bad idea}  % Common foot for two cards

\begin{flashcard}
[1 $\spadesuit$ ]              % header  (optional)
{A big hoopla about nothing}   % front 
\spade                         % back  
\end{flashcard}


\begin{flashcard}
[2 $\spadesuit$]
{A wheelchair death race}
\spade
\end{flashcard}

\cardfrontfoot{The Canadian Expansion.\\ No really, don't google this at work.}

\begin{flashcard}
[1 $\clubsuit$ ]               
{Burning down the White House}
\club
\end{flashcard}

\begin{flashcard}
[2 $\clubsuit$ ]               
{Terry Fox's prosthetic leg}
\club
\end{flashcard}

\begin{flashcard}
[3 $\clubsuit$ ]               
{The Offical Languages Act\\ \vspace{3\baselineskip} \noindent La Loi sur les langues officielles}
\club
\end{flashcard}

\begin{flashcard}
[4 $\clubsuit$ ]               
{The Front de Libération du Québec\vfill}
\club
\end{flashcard}

\begin{flashcard}
[5 $\clubsuit$ ]               
{Poutine}
\club 
\end{flashcard}

\begin{flashcard}
[6 $\clubsuit$ ]               
{Killing a Moose with your bare hands}
\club
\end{flashcard}

\cardfrontfoot{The Second Expansion. \\This if a card game for horrible people.}


\begin{flashcard}
[\textcolor{red}{1 $\heartsuit$}]               
{A piñata full of scorpions}
\heart  
\end{flashcard}

\end{document}

enter image description here

share|improve this answer
add comment

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.