我想画出来,但是
因此我可以制作一部分,但质量仍然不高
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds}
\usepackage{verbatim}
\begin{document}
\pagestyle{empty}
\begin{center}
\def\firstcircle{(0,0) circle (1cm)}
\def\secondcircle{(2,0) circle (1cm)}
\def\thirdcircle{(1,1.7) circle (1cm)} \qquad
\def\firstcircle{(5,0) circle (1cm)}
\def\secondcircle{(7,0) circle (1cm)}
\def\thirdcircle{(6,1.7) circle (1cm)}
\begin{tikzpicture}
\draw \firstcircle node[below] {$K$};
\draw \secondcircle node [above] {$K$};
\draw \thirdcircle node [below] {$K$};
\end{tikzpicture} \qquad
\begin{tikzpicture}
\draw \firstcircle node[below] {$C$};
\draw \secondcircle node [above] {$C$};
\draw \thirdcircle node [below] {$C$};
\end{tikzpicture}
\end{center}
\end{document}
答案1
由于所有答案都使用 tikz,因此只是为了好玩而使用适度的\textcircled
:
\documentclass[12pt]{article}
\usepackage[letterspace=-125]{microtype}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\def\K{\textcircled{\scriptsize{\bfseries K}}}
\begin{document}
\scalebox{6}{\begin{minipage}[c]{2cm}
\lsstyle\sffamily\lineskip1.25pt
\lineskiplimit50pt %large enough ...
\centering
\K\\\K\K\\\K\K\K\\\K\K\K\K\\\K\K\K\K\K
\end{minipage}}
\end{document}
\Kr
使用包的命令可以获得类似的结果harmony
:
\documentclass{article}
\usepackage{harmony}
\def\K{\Kr{K}}
\begin{document}
{\parindent0pt\bfseries\centering\obeylines
\K
\K\K
\K\K\K
\K\K\K\K
\K\K\K\K\K
}
\end{document}
答案2
干净一点。
\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\foreach \n in {1,2,3,4}
\foreach \m in {1,...,\n}
\node[circle,draw,minimum size=1cm] at ($(60:\m cm)+(-\n cm,0)$) {K};
\end{tikzpicture}
\end{document}
答案3
这就是你想要的东西吗?
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\draw[red] (0,0)--(3,0);
\draw[red] (0,0)--(60:3cm);
\draw[red] (3,0)--++(120:3cm);
\node[circle,draw,minimum size=1cm](a-1) {K};
\node[circle,draw,minimum size=1cm](b-1) at (60:1cm) {K};
\node[circle,draw,minimum size=1cm](c-1) at (60:2cm) {K};
\node[circle,draw,minimum size=1cm](d-1) at (60:3cm) {K};
\node[circle,draw,minimum size=1cm,right=0mm of a-1](a-2){K};
\node[circle,draw,minimum size=1cm,right=0mm of a-2](a-3){K};
\node[circle,draw,minimum size=1cm,right=0mm of a-3](a-4){K};
\node[circle,draw,minimum size=1cm,right=0mm of b-1](b-2){K};
\node[circle,draw,minimum size=1cm,right=0mm of b-2](b-3){K};
\node[circle,draw,minimum size=1cm,right=0mm of c-1](c-2){K};
\end{tikzpicture}
\end{document}
答案4
另一种选择,代码比某些代码更简洁,但不如曼努埃尔.本解决方案使用该chains
库。
\documentclass[tikz, border=5pt, varwidth, multi]{standalone}
\usetikzlibrary{chains,scopes}
\begin{document}
\begin{tikzpicture}
[
node distance=0mm,
every on chain/.style={draw, circle, minimum width=10mm},
font=\sffamily\bfseries
]
{[start chain=main going {at=(\tikzchainprevious), shift=(-60:10mm)}]
\foreach \i in {1,...,4}
\node (k\i) [on chain] {K};
\foreach \i in {2,3,4}
{[start chain=ck\i going left]
\chainin (k\i);
\foreach \j in {2,...,\i}
\node [on chain=going left] {K};
}
}
{[start chain=other going {at=(\tikzchainprevious), shift=(-60:10mm)}, xshift=50mm]
\foreach \i in {1,...,4}
\node (c\i) [on chain] {C};
\foreach \i in {2,3,4}
{[start chain=cc\i going left]
\chainin (c\i);
\foreach \j in {2,...,\i}
\node [on chain=going left] {C};
}
}
\end{tikzpicture}
\end{document}
如果你需要很多堆硬币,你可能更喜欢使用pic
。以下代码定义了一个 ,pic
它有 3 个参数。第一个参数指定每枚硬币的内容,例如C
或K
,第二个参数指定金字塔中的行数4
,例如 ,第三个参数指定每枚硬币的最小直径,例如10mm
。
一堆硬币可以定义为
\pic [<options>] {coins={<content>}{<rows>}{<diameter>}};
<options>
例如,可以用来改变硬币的颜色或将其向左或向右移动。
\documentclass[tikz, border=5pt, varwidth, multi]{standalone}
\usetikzlibrary{chains,scopes}
\begin{document}
\tikzset{
pics/coins/.style n args={3}{
code={
\begin{scope}
[
node distance=0mm,
inner sep=0pt,
every on chain/.style={draw, circle, minimum width=#3, pic actions},
font=\sffamily\bfseries,
start chain=main going {at=(\tikzchainprevious), shift=(-60:#3)},
pic actions
]
\foreach \i in {1,...,#2}
\node (#1\i) [on chain] {#1};
\foreach \i in {2,...,#2}
{[start chain=c#1\i going left]
\chainin (#1\i);
\foreach \j in {2,...,\i}
\node [on chain=going left] {#1};
}
\end{scope}
},
},
}
\begin{tikzpicture}
\pic [inner color=gray!25, outer color=gray!50, draw=gray, text=black] {coins={K}{4}{10mm}};
\pic [green] at (50mm,0) {coins={C}{8}{5mm}};
\pic [yshift=-50mm, xshift=25mm, inner color=yellow!50!orange!25, outer color=yellow!50!orange!50, draw=yellow!25!orange!50!black, text=yellow!25!orange!50!black] {coins={1p}{5}{15mm}};
\end{tikzpicture}
\end{document}