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?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI'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?
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}
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}
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 '19 at 4:35
Run with xelatex
:
\documentclass{article}
\usepackage{pst-poker}
\begin{document}
\crdAs \crdtenh \crdsevd \crdsevc \crdQd
\end{document}
or with pdflatex --shell-escape <file>
:
\documentclass{article}
\usepackage{pstricks-pdf}
\usepackage{pst-poker}
\begin{document}
\begin{postscript}
\crdAs \crdtenh \crdsevd \crdsevc \crdQd
\end{postscript}
\end{document}
pdflatex
may not work without further ado for PStricks based packages. – user194703 Oct 30 '19 at 2:53