我是 Tzik 的新手,只具备基础知识,但我想用非数字符号标记多边形的顶点?
但我只有
\begin{figure}[h]
\centering
\begin{tikzpicture}[rotate=45]
\foreach \a in {0,90,180,270} { %\a is the angle variable
\draw[line width=.7pt,black,fill=black] (\a:1.5cm) coordinate (a\a) circle (2pt); }
\draw [line width=.7pt,black,fill=orange] (a0) -- (a90) -- (a180) -- (a270) -- cycle;
\end{tikzpicture}
\hspace{3cm}
\begin{tikzpicture}[rotate=22.5]
\foreach \a in {0,45,90,135,180,225,270,315} { %\a is the angle variable
\draw[line width=.7pt,black,fill=black] (\a:1.5cm) coordinate (a\a) circle (2pt); }
\draw [line width=.7pt,black,fill=orange] (a0) -- (a45) -- (a90) -- (a135) -- (a180) -- (a225) -- (a270) -- (a315) -- cycle;
\end{tikzpicture}
\end{figure}
有人能帮助我吗?
答案1
\foreach
可用于循环遍历值对(或更一般的元组):
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[rotate=22.5]
\foreach \a/\l in {0/a,45/b,90/c,135,180,225,270,315} { %\a is the angle variable
\draw[line width=.7pt,black,fill=black] (\a:1.5cm) coordinate (a\a) circle (2pt);
\node[anchor=202.5+\a] at ($(a\a)+(\a+22.5:3pt)$) {\l};
}
\draw [line width=.7pt,black,fill=orange] (a0) -- (a45) -- (a90) -- (a135) -- (a180) -- (a225) -- (a270) -- (a315) -- cycle;
\end{tikzpicture}
\end{document}
为每个点添加一个带有实际标签的标签节点。使用\usetikzlibrary{calc}
前言中的锚点和需求对位置进行微调。