14

I'm writing some probability lectures and would like to typeset some playing cards.

I'm aware of the poker and pst-poker packages, but can't get them to work. Is there a less sophisticated way to typeset playing cards?

  • Possibly the fact that it does not work is related to your choice of compiler. E.g. pdflatex may not work without further ado for PStricks based packages. – Schrödinger's cat Oct 30 at 2:53
  • 1
    I'm sure it's possible, but I'd like a solution compatible with my current latex setup. – Brian Fitzpatrick Oct 30 at 2:54
  • 4
    Well, yes, but how would anyone know what your current latex setup is? – Schrödinger's cat Oct 30 at 2:55
  • 1
    What I mean is, I'm curious if there are other solutions. Whether those other solutions work with my setup will be my problem. – Brian Fitzpatrick Oct 30 at 2:58
  • Possible duplicate: How to draw the cards of a deck?. – Paul Gaborit Oct 30 at 9:42
19

EDITED to flip-the-pip in the lower right of the card (hat tip Aofl), and to add a club (flower) suit example:

\documentclass{article}
\usepackage{tabstackengine,xcolor,rotating}
\newcommand\blackcard[2]{%
  \begingroup\fboxsep=0pt\relax
  \fbox{\tabbedCenterstack{%
  \scriptsize$#2$ && \\&\makebox[10pt]{#1}&\\&
  &\rotatebox[origin=c]{180}{\scriptsize$#2$}}}%
  \endgroup}
\newcommand\redcard[2]{%
  \begingroup\fboxsep=0pt\relax
  \fbox{\color{red}\tabbedCenterstack{%
  \scriptsize$#2$ && \\&\makebox[10pt]{#1}&\\&&\rotatebox[origin=c]{180}{\scriptsize$#2$}}}%
  \endgroup}
\begin{document}
\blackcard{Q}{\spadesuit}
\redcard{10}{\heartsuit}
\blackcard{8}{\clubsuit}
\redcard{A}{\diamondsuit}
\end{document}

enter image description here

I thank corporal for stepping in, in my absence, to help with some of the OP's follow-up questions (HOOAH!). Here, I employ his suggestions, though making some small changes, to account for different glyph widths among the packages.

The Joker I provide gratis.

\documentclass{article}
\usepackage{tabstackengine,xcolor,txfonts,fancybox,arev,graphicx}
\cornersize{.1}
\newcommand\blackcard[2]{%
  \begingroup\fboxsep=0pt\relax
  \Ovalbox{\tabbedCenterstack{%
  \makebox[0pt][l]{\scriptsize$#2$} && \\
    &\makebox[22pt]{#1}&\\
    &&\makebox[0pt][r]{\rotatebox[origin=c]{180}{\scriptsize$#2$}}}}%
  \endgroup}
\newcommand\redcard[2]{%
  \begingroup\fboxsep=0pt\relax
  \Ovalbox{\color{red}\tabbedCenterstack{%
  \makebox[0pt][l]{\scriptsize$#2$} && \\
    &\makebox[22pt]{#1}&\\
    &&\makebox[0pt][r]{\rotatebox[origin=c]{180}{\scriptsize$#2$}}}}%
  \endgroup}
\newcommand\jokerface{\raisebox{-2pt}{\kern-1pt\stackengine{0pt}{%
  \stackinset{c}{1pt}{c}{-.4pt}{\stackunder[.7pt]{$\cdot\kern2pt\cdot\kern0.3pt$}%
  {--}}{$\bigcirc$}}{\,$\steaming$}{O}{c}{F}{F}{S}}}
\newcommand\joker{\vcenter{\hbox{\scalebox{.4}{ \tiny JOKER }}}}
\begin{document}
\blackcard{Q}{\spadesuit}
\redcard{10}{\varheartsuit}
\redcard{A}{\vardiamondsuit}
\blackcard{\jokerface}{\joker}
\end{document}

enter image description here

  • 1
    Any chance on rounding off the corners to make it 'prettier' – 3kstc Oct 30 at 4:09
  • 1
    @3kstc. One way to obtain rounded corners is to use the fancybox package and change \fbox to \Ovalbox or \ovalbox, and use \cornersize{0.1}. The \blackcard \def becomes \newcommand\blackcard[2]{% \begingroup\fboxsep=0pt\relax \cornersize{.1}\Ovalbox{\tabbedCenterstack{% \scriptsize$#2$ && \\&\makebox[10pt]{#1}&\\&&\scriptsize$#2$}}% \endgroup} – corporal Oct 30 at 4:35
  • 1
    And also fill in the heart and diamonds in red to make it consistent with the spades theme. – 3kstc Oct 30 at 4:37
  • 2
    Where's the flower card? :-) – Sebastiano Oct 30 at 8:47
  • 2
    @StevenB.Segletes Sebastiano is referring to "clubs"... They're called fiori, flowers, in Italian. – Rmano Oct 30 at 20:01
3

Run with xelatex:

\documentclass{article}
\usepackage{pst-poker}
\begin{document}    
\crdAs \crdtenh \crdsevd \crdsevc \crdQd
\end{document}

enter image description here

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.