![将两个包中的环境合并起来?](https://linux22.com/image/466017/%E5%B0%86%E4%B8%A4%E4%B8%AA%E5%8C%85%E4%B8%AD%E7%9A%84%E7%8E%AF%E5%A2%83%E5%90%88%E5%B9%B6%E8%B5%B7%E6%9D%A5%EF%BC%9F.png)
我使用 tikz 包制作了一个图形,并想使用 tikzducks 包制作图形的顶点。(具体来说,我想用彩色鸭子替换任意图形顶点的点)。这可能吗?
这是我的代码:
\begin{tikzpicture}[node distance={15mm}, thick, main/.style = {draw, circle}]
\node[main] (1) {};
\node[main] (2) [above right of=1] {} ;
\node[main] (3) [below right of=1] {} ;
\node[main] (4) [above right of=3] {} ;
\node[main] (5) [above right of=4] {} ;
\node[main] (6) [below right of=4] {} ;
\draw (1) -- (2);
\draw (1) -- (3);
\draw (1) to [out=135,in=90,looseness=1.5] (5);
\draw (1) to [out=180,in=270,looseness=5] (1);
\draw (2) -- (4);
\draw (3) -- (4);
\draw (5) -- (4);
\draw (5) to [out=315, in=315, looseness=2.5] (3);
\draw (6) -- node[midway, above right, sloped, pos=1] {} (4);
\end{tikzpicture}
答案1
除了普通的tikzducks
包之外,还有一个 tikz 库,可以让你把鸭子用作 tikz pic
:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,ducks}
\begin{document}
\begin{tikzpicture}[
node distance={15mm},
thick, main/.style = {},
quack/.style = {scale=0.15,xshift=-0.8cm,yshift=-0.8cm}
]
\node[main] (1) {};
\node[main] (2) [above right of=1] {} ;
\node[main] (3) [below right of=1] {} ;
\node[main] (4) [above right of=3] {} ;
\node[main] (5) [above right of=4] {} ;
\node[main] (6) [below right of=4] {} ;
\pic[quack] at (1) {duck};
\pic[quack] at (2) {duck};
\pic[quack,duck/body=red] at (3) {duck};
\pic[quack] at (4) {duck};
\pic[quack,duck/body=green] at (5) {duck};
\pic[quack] at (6) {duck};
\draw (1) -- (2);
\draw (1) -- (3);
\draw (1) to [out=135,in=90,looseness=1.5] ([yshift=7pt]5);
\draw (1) to [out=180,in=270,looseness=5] (1);
\draw (2) -- (4);
\draw (3) -- (4);
\draw (5) -- (4);
\draw (5) to [out=315, in=315, looseness=2.5] (3);
\draw (6) -- node[midway, above right, sloped, pos=1] {} (4);
\end{tikzpicture}
\end{document}