我学会了这里来自 enzo83130 和 percusse 来画一根火柴,但我还不知道如何画一堆:
\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}
答案1
在这里我将单位匹配保存为,\match
然后使用stackengine
和/或tabstackengine
包中的各种堆叠命令。它可以针对水平和垂直堆叠间隙进行自定义。
\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}
为了好玩,这是[咖啡]豆版本
\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}