7

How to draw the cards from a deck using a Latex package, as TikZ?enter image description here

  • 12
    \includegraphics{} – Holene Oct 19 '14 at 10:00
  • 1
    Excuse me. I know insert a figure. What I want is to learn how to draw using a tool of Latex. – benedito Oct 19 '14 at 10:04
  • 5
    Whereas the some of the (number) cards could be drawn with tikz, pstricks etc, especially the cards showing images like King, Queen, Joker, Jake are too complex to draw it with tikz. – user31729 Oct 19 '14 at 10:09
  • 7
    Please review the answers you've got to your other questions and consider accepting the most deserving ones: tex.stackexchange.com/users/36688/benedito?tab=questions – jub0bs Oct 19 '14 at 10:14
  • 5
    Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. – Andrew Swann Oct 19 '14 at 10:18
10

Here is a solution using SVG-Cards, inkscape and PDFLaTEX/graphicx/TikZ.

I provide a Makefile :

  • to download and to extract the SVG-Cards archive (via wget and tar),

  • to extract each SVG card from svg-cards.svg (via inkscape)

  • to convert each SVG card into a PDF card (via inkscape)

  • to compile cards.tex (via pdflatex)

Steps:

  1. Copy the Makefile (note: the white spaces at beginning of lines are tabulations) and the cards.tex below.

  2. Run make to get cards.pdf

Note: if you can't use this Makefile, I provide cards.tgz. This archive contains all extracted PDF cards (needed to compile cards.tex).

enter image description here

The Makefile:

JOKERS = black_joker red_joker
LEVELS = 1 2 3 4 5 6 7 8 9 10 jack queen king
CLUBS = ${LEVELS:%=%_club}
DIAMONDS = ${LEVELS:%=%_diamond}
HEARTS = ${LEVELS:%=%_heart}
SPADES = ${LEVELS:%=%_spade}
CARDS = ${CLUBS} ${DIAMONDS} ${HEARTS} ${SPADES} ${JOKERS}
CARDS_PDF = ${CARDS:%=card-%.pdf}

all: cards.pdf

cards.pdf: cards.tex $(CARDS_PDF)
    latexmk -pdf cards.tex

card-%.pdf: card-%.svg
    inkscape --export-pdf=$@ $<

card-%.svg: SVG-cards-2.0.1/svg-cards.svg
    inkscape --export-plain-svg=$@ --export-id=${@:card-%.svg=%} --export-id-only $<

SVG-cards-2.0.1/svg-cards.svg:
    wget http://sourceforge.net/projects/svg-cards/files/SVG-cards-2.0.1.tar.gz
    tar zxvf SVG-cards-2.0.1.tar.gz

The cards.tex file:

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
  \foreach \col[count=\c] in {spade,heart,diamond,club}{
    \begin{scope}[shift={(\c*90:1.5cm)}]
      \foreach \level[count=\val] in {1,...,10,jack,queen,king}{
        \node[inner sep=0,anchor=south,rotate={40-(\val*6)}]
        at ({140-(\val*6)}:1cm)
        {\includegraphics[height=1cm]{card-\level_\col}};
      }    
    \end{scope}
  }
  \node at (-2,0) {\includegraphics[height=1cm]{card-red_joker}};
  \node at (2,0)  {\includegraphics[height=1cm]{card-black_joker}};
\end{tikzpicture}
\end{document}
  • Do you know how to do this in Windows without cygwin? That's my work platform. – skpblack Oct 21 '14 at 1:39
  • @skpblack pdflatex, latexmk and inkscape exist for Windows. You may download manually the SVG-Cards archive then try GnuWin (a gnumake for windows)... – Paul Gaborit Oct 21 '14 at 5:19
  • @skpblack : I added a note with a link to an archive with all PDF cards – Paul Gaborit Oct 21 '14 at 8:11
  • This is such a great contribution. I used it to illustrate a Venn diagram intersection. FYI docdro.id/KaJUDjw – PatrickT Oct 9 '17 at 21:30
24

The closest solution I found is the experimental package poker developed by Olaf Encke. This package is based on PSTricks (with all complications to run in pdflatex) further that this package is not standard and generally is not included in the Standard TeX Distributions (MaCTeX, TeXLive or MiKTeX) and it must be manually installed.

I recommend these steps:

Code Example

\documentclass{article}
\usepackage{poker}
\pagestyle{empty} %No number in pages
\begin{document}

\begin{cards}
\crdAs\crdKh
\end{cards}

\begin{cards}
\crdpair{\crdKs}{\crdtenh}%
\crdflop{\crdsevd}{\crdsevc}{\crdQd}%
\crdKc\crdKd%
\end{cards}

\end{document}

Result

enter image description here

  • Now we have the pst-poker package which is included in TeX Live. Its document says "pst-poker is based on the package poker from Olaf Encke (web.mit.edu foley/games/Arcadia/sr/poker/pokersty)." – L. F. Mar 29 at 14:10
21

Depends what you want to do with them. If you going to enter them in a paper to describe probabilities etc, better to use a font. As of Unicode 7.0 there are codepoints for card suite. Use the Symbola free font of George Douros.

\documentclass{article}
\usepackage{fontspec}
\newfontfamily\symbola{Symbola.ttf}
\begin{document}
\Huge
\symbola
\char"1F0AB \char"1F0CF
\end{document}

Use XeLaTeX or LuaLaTeX.

enter image description here

With a unicode font you can just type "The drawn trump suit from the draw deck is a ♣ card (2♣)." and typeset the text easily.

enter image description here

  • In addition to your answer: Here are all possible cards of the unicode, here you get closer information on each code, and here, you may check which fonts on your system support that symbol. – LaRiFaRi Oct 21 '14 at 8:27
  • 1
    @LaRiFaRi Thanks for the links. I am aware of some of the other fonts, they are hard to come by (if you see in your link) there only about three other fonts you can use. The Quivira is a particularly good one as well, so are the No Tofu from Google. The last one is very lightweight and has an advantage if you don't mix it with other text. – Yiannis Lazarides Oct 21 '14 at 13:48

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.