我对编码还很陌生,完全不知道自己在做什么。
\begin{tikzpicture}[
mystyle/.style = {draw,shape=circle,fill=blue}
]
\def\ngon{4}
\node[regular polygon,regular polygon sides=\ngon,minimum size=5cm] (p) {};
\foreach \x in {1,...,\ngon}{
\node[mystyle] (p\x) at (p.corner \x){};
}
\foreach \x in {1,...,\numexpr\ngon-1\relax}{
\foreach\y in {\x,...,\ngon}{
\draw (p\x) -- (p\y);
}
}
\end{tikzpicture}
答案1
答案2
欢迎使用 TeX.SE!我会使用\ifnum
它。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}[
mystyle/.style = {draw,shape=circle,fill=blue}
]
\def\ngon{4}
\node[regular polygon,regular polygon sides=\ngon,minimum size=5cm] (p) {};
\foreach \x in {1,...,\ngon}{
\ifnum\x=2
\coordinate (p\x) at (p.corner \x);
\else
\node[mystyle] (p\x) at (p.corner \x){};
\fi
}
\foreach \x in {1,...,\numexpr\ngon-1\relax}{
\foreach\y in {\x,...,\ngon}{
\draw (p\x) -- (p\y);
}
}
\end{tikzpicture}
\end{document}