2

I learned here from enzo83130 and percusse to draw a match stick, but I do not know how to draw a pile yet:

\documentclass{article}

\usepackage[svgnames]{xcolor}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\newcommand\allumette[2]{
    \fill [yellow] (#1,#2) rectangle (#1+4,#2+0.2);
    \fill [yellow!60!black] (#1,#2) -- ++(4,0)-- ++(0.1,-0.05) -- ++(-4,0) -- ++(-0.1,0.05);
    \draw (#1,#2) -- ++(0,0.2) -- ++(4,0) -- ++(0,-0.2) -- ++(0.1,-0.05) -- ++(-4,0) -- ++(-0.1,0.05);
    \shade[ball color=red] (#1+4,#2+0.1) ellipse (0.25cm and 0.22cm);
    \draw (#1+4,#2+0.1) ellipse (0.25cm and 0.22cm);
}
\allumette{0.1}{0.2}
\end{tikzpicture}

\end{document}

enter image description here

benedito
  • 4,600
  • 1
    Where is here? Code should be attributed and should include a link to the original. – cfr Dec 27 '16 at 14:12
  • Sorry. It was bad. – benedito Dec 27 '16 at 14:12
  • The link: https://tex.stackexchange.com/questions/344598/draw-a-match-using-tikz?rq=1 – benedito Dec 27 '16 at 14:17
  • What does this have to do with bean seeds? What have you tried? You can just put more matches wherever you wish by repeating the command with new coordinates. – cfr Dec 27 '16 at 14:17
  • How do you want the pile of matches look like? – gernot Dec 27 '16 at 14:18
  • I have no preference. I want the stack just to illustrate a problem about games, where each player remove one or more sticks. – benedito Dec 27 '16 at 14:21
  • Maybe http://tex.stackexchange.com/a/163828/15874 can help you with a PSTricks solution. – Svend Tveskæg Dec 27 '16 at 14:32
  • @gernot For what it is worth, I don't find this question to be a duplicate of the one cited. That one is about "drawing" whereas this one is, to my view, all about "stacking". Drawing, while more comprehensive in its scope, carries a lot of extra code baggage that I don't think is needed for the current application. – Steven B. Segletes Dec 27 '16 at 18:43

1 Answers1

5

Here I save the unit match as \match and then use various stacking commands from stackengine and/or tabstackengine packages. It can be customized for horizontal and vertical stacking gaps.

\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{tikz,tabstackengine}
\savestack\match{\begin{tikzpicture}\fill [yellow] (0,0) rectangle (4,0.2);
    \fill [yellow!60!black] (0,0) -- ++(4,0)-- ++(0.1,-0.05) -- ++(-4,0) -- ++(-0.1,0.05);
    \draw (0,0) -- ++(0,0.2) -- ++(4,0) -- ++(0,-0.2) -- ++(0.1,-0.05) -- ++(-4,0) -- ++(-0.1,0.05);
    \shade[ball color=red] (4,0.1) ellipse (0.25cm and 0.22cm);
    \draw (4,0.1) ellipse (0.25cm and 0.22cm);\end{tikzpicture}}
\begin{document}
\setstacktabbedgap{2pt}
\setstackgap{S}{0pt}
\tabbedShortstack{%
\match&&\\
\match&&\match\\
\match&\match&\match\\
\match&\match&\match
}

\bigskip
\setstackgap{S}{-1pt}
\Shortstack{\match\\\match\match\\\match\match\match}

\bigskip
\Shortstack[r]{\match\\\match\match\\\match\match\match}
\end{document}

enter image description here

For fun, here is the [coffee] bean version

\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{tikz,tabstackengine}

\savestack\bean{%
  \stackinset{c}{}{c}{}{\color{white}\rotatebox[origin=center]{45}{%
  \sffamily\scalebox{.4}[1.2]{S}}}{%
  \color{brown!70!black}\scalebox{2}[1.5]{$\bullet$}}}\begin{document}  
\setstacktabbedgap{-2pt}
\setstackgap{S}{-2pt}
\tabbedShortstack{%
\bean&&\\
\bean&&\bean\\
\bean&\bean&\bean\\
\bean&\bean&\bean
}

\bigskip
\setstackgap{S}{-3.5pt}
\Shortstack{\bean\\\bean\bean\\\bean\bean\bean}

\bigskip
\setstackgap{S}{-1pt}
\Shortstack[r]{\bean\\\bean\bean\\\bean\bean\bean}
\end{document}

enter image description here