大家好,我有这张图片,我想通过在边缘上添加名称来使它变得更好。例如,我想让连接 1 和 4 的边缘成为$\theta_1 \theta_4$
所有边缘的代名词。非常感谢,我非常感谢阅读此文的任何人提供的帮助和时间!
\begin{tikzpicture}[transform shape]
\foreach \x in {1,...,4}{%
\pgfmathparse{(\x-1)*360/4}
\node[draw,circle,inner sep=0.15cm] (N-\x) at (\pgfmathresult:1.4cm) {\x};
}
\foreach \x [count=\xi from 1] in {1,...,4}{%
\foreach \y in {\x,...,4}{%
\path (N-\x) edge[ultra thin,-] (N-\y);
}
}
\end{tikzpicture}
答案1
node
您可以通过沿边缘放置 s 来实现这一点。这是一个次优但自动化的解决方案。当然,您可以手动放置edge
s 和node
s ,然后选择node
s 应该出现在红色 的位置node
。
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x in {1,...,4}{%
\pgfmathparse{(\x-1)*360/4}
\node [draw,circle,inner sep=0.15cm] (N-\x) at (\pgfmathresult:1.4cm) {\x};
}
\foreach \x in {1,...,4}{%
% because there is no need to draw an edge to the starting node itself
% start at index 2 in the second loop
\foreach \y in {2,...,4}{%
% also the edge should only be drawn, if \x is smaller than \y
\ifnum \x<\y
\path (N-\x) edge [ultra thin,-]
node [auto,swap] {$\theta_{\x} \theta_{\y}$}
(N-\y);
\fi
}
}
% edge placed by hand
\path (N-1) edge [ultra thin,-]
node [auto,red] {$\theta_{1} \theta_{4}$}
(N-4);
\end{tikzpicture}
\end{document}