只画一个,后面的你可以选择套用循环,或者复制粘贴
\documentclass{ctexart}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node [ circle, draw ] (a) {};
\node [ circle, draw, fill, xshift = 1cm ] (b) at (a) {};
\node [ circle, draw, fill, shift = {({sin(18)}, {cos(18)})} ] (c) at (b) {};
\node [ circle, draw, fill, shift = {({-cos(36)}, {sin(36)})} ] (d) at (c) {};
\node [ circle, draw, fill, shift = {({-cos(36)}, {-sin(36)})} ] (e) at (d) {};
\draw (a) -- (b) -- (c) -- (d) -- (e) -- (a);
\end{tikzpicture}
\end{document}
其实后面的图麻烦
我的TikZ
还是不太熟练...稍微封装了一下
\documentclass[border=8pt]{standalone}
\usepackage{tikz}
\usepackage{xfp}
\newcommand*{\drawpentagon}[1]{%
\draw ({-#1*sin(18)},{#1*cos(18)}) -- (0,0) -- (#1,0);
\ifnum#1=0
\node [ circle, fill = white, draw , label={[yshift=-3pt]below:{\textbf{1}}}] {};
\else
\foreach \i in {1,...,#1}
{
\ifodd \i
\node [ circle, fill = white, draw ] (a) {};
\node [ circle, draw, fill, xshift = \i*1cm ] (b) at (a) {};
\node [ circle, draw, fill, shift = {({sin(18)*\i*1cm}, {cos(18)*\i*1cm})} ] (c) at (b) {};
\node [ circle, draw, fill, shift = {({-cos(36)*\i*1cm}, {sin(36)*\i*1cm})} ] (d) at (c) {};
\node [ circle, draw, fill, shift = {({-cos(36)*\i*1cm}, {-sin(36)*\i*1cm})} ] (e) at (d) {};
\draw (b) -- (c) -- (d) -- (e);
\else
\node [ circle, draw ] (a) {};
\node [ circle, draw, fill = white, xshift = \i*1cm ] (b) at (a) {};
\node [ circle, draw, fill = white, shift = {({sin(18)*\i*1cm}, {cos(18)*\i*1cm})} ] (c) at (b) {};
\node [ circle, draw, fill = white, shift = {({-cos(36)*\i*1cm}, {sin(36)*\i*1cm})} ] (d) at (c) {};
\node [ circle, draw, fill = white, shift = {({-cos(36)*\i*1cm}, {-sin(36)*\i*1cm})} ] (e) at (d) {};
\draw (b) -- (c) -- (d) -- (e);
\fi
}
\draw [ dashed ] (a) -- (d);
\draw [ dashed ] (a) -- (c);
\node[label=below:{\textbf{\fpeval{{#1}*4+1}}}] at (#1/2,-3pt) {};
\fi
}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\drawpentagon{0}
\end{scope}
\begin{scope}[xshift=3cm]
\drawpentagon{1}
\end{scope}
\begin{scope}[xshift=7cm]
\drawpentagon{2}
\end{scope}
\begin{scope}[xshift=12cm]
\drawpentagon{3}
\end{scope}
\end{tikzpicture}
\end{document}
但不知道你观察仔细与否,上面的图仍然有瑕疵。dashed line
has truded in the circle.一般情况下先画虚线再画圆可以搞定,但此处需要先确定外侧的node
,我没想到什么很elegant
的方法...再次求助S老师@u79794 嘤嘤嘤.
@u70550 对于这个问题我来自答一下。优雅的方式是是用on background layer
创建一个位于底层的scope
. Following link: https://tex.stackexchange.com/questions/731186/how-to-put-the-node-after-the-futuring-assigned-node-in-the-foreach-loop/731193#731193.
谢谢!厉害
附上一个第四张小图画法,用了奇偶判断
@u79794 这不顺便封装一个命令(?)
@u79794 谢谢!厉害!
@u79794 后面横线中的那些小点点我还是用麻烦的方法补上了,多谢!
@u70550 你咋不说让我直接写个包😡👊