7

I want to create sheets of playing cards for a game. There isn't a known package for this, however stealing from a previous answer and deleting things until it made sense got me this far:

\documentclass{article}
\usepackage[margin=2cm]{geometry}

\newlength\cardheight
\newlength\cardwidth

\setlength\cardheight{0.25\textheight}
\setlength\cardwidth{0.4\textwidth}

\newcommand\cards[1]{%
\par\noindent
\fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax} 
\vspace{\baselineskip}
\LARGE ~ #1 
\vfill
\small ~ Cards Against Humanity %I should insert the CAH logo in my final version
\end{minipage}} %\par\bigskip%
} %


\pagestyle{empty}

\begin{document}
\centering
\cards{%
Classicist undertones.
}
\cards{%
A windmill full of corpses.
}
\cards{%
A tiny horse.
}

\end{document}

However, this gets me three cards stacked on top of one another. How can I get them to tile automatically (So it goes something like card:card:card, newrow card:card:card)? The exact number of cards that each page has horizontally and vertically doesn't matter; I just want each card to sit next to each other instead of each new one appearing on a new line.

(Feel free to abandon my code if there is a better way to do this: As I said, I just copied it from an example that was only sort of related.)

8

Simply removing \par\noindent should be OK. Also, there is a spurious space in the line

\end{minipage}} %\par\bigskip%

Complete code

\documentclass{article}
\usepackage[margin=2cm]{geometry}

\newlength\cardheight
\newlength\cardwidth

\setlength\cardheight{0.25\textheight}
\setlength\cardwidth{0.4\textwidth}

\newcommand\cards[1]{%
\fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax}
\vspace{\baselineskip}
\LARGE ~ #1
\vfill
\small ~ Cards Against Humanity %I should insert the CAH logo in my final version
\end{minipage}}% there was a space here
}


\pagestyle{empty}

\begin{document}
\centering
\cards{%
Classicist undertones.
}
\cards{%
A windmill full of corpses.
}
\cards{%
A tiny horse.
}
\cards{%
One more card.
}

\end{document} 

Output:

enter image description here

You might also want a very little horizontal space between them. To achieve it, you can add \hspace{1pt} after the end of the \fbox and put a % after each \cards:

\documentclass{article}
\usepackage[margin=2cm]{geometry}

\newlength\cardheight
\newlength\cardwidth

\setlength\cardheight{0.25\textheight}
\setlength\cardwidth{0.4\textwidth}

\newcommand\cards[1]{%
\fbox{\begin{minipage}[t][\cardheight][t]{\dimexpr\cardwidth-2\fboxsep-2\fboxrule\relax}
\vspace{\baselineskip}
\LARGE ~ #1
\vfill
\small ~ Cards Against Humanity %I should insert the CAH logo in my final version
\end{minipage}}% there was a space here
\hspace{1pt}}


\pagestyle{empty}

\begin{document}
\centering
\cards{%
Classicist undertones.
}%
\cards{%
A windmill full of corpses.
}%
\cards{%
A tiny horse.
}%
\cards{%
One more card.
}%

\end{document} 

Output:

enter image description here

  • You have no idea how embarrassed I am to have missed that. – Canageek Nov 26 '13 at 5:46
  • @Canageek Don't worry for that. BTW, I've added something in the answer... – karlkoeller Nov 26 '13 at 5:49
  • Thanks. That also fixes a problem I was having with them not aligning horizontally. – Canageek Nov 26 '13 at 5:53

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.