我画了三个圆圈:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
\draw (0.0, 0.3) circle [radius=0.45] node (a) {$\alpha$};
\draw (1.6, 0.3) circle [radius=0.45] node (b) {$\beta$};
\draw (3.2, 0.3) circle [radius=0.45] node (c) {$\gamma$};
\end{tikzpicture}
\end{document}
我现在想在边缘如下图所示的圆圈:
我尝试使用\draw [->] (a) -- (b);
,但箭头两端都进入了圆圈内?我这里遗漏了什么?
答案1
这样做要容易得多,因为节点代表圆圈,而不仅仅是希腊字母
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\node[minimum width=1cm,draw,circle] (a) at (0,0) {$\alpha$};
\node[minimum width=1cm,draw,circle] (b) at ($(a)+(2,0)$) {$\beta$};
\node[minimum width=1cm,draw,circle] (c) at ($(b)+(2,0)$) {$\gamma$};
\draw[->] (a) -- (b);
\draw[->] (c) -- (b);
\end{tikzpicture}
\end{document}
答案2
与@daleif 答案类似(+1),但具有节点的相对定位和为圆圈定义的通用样式:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 0mm and 9mm,
C/.style = {circle, draw, minimum size =9mm, inner sep=0pt},
arr/.style = {-Straight Barb, semithick}
]
\node (a) [C] {$\alpha$};
\node (b) [C, right=of a] {$\beta$};
\node (c) [C, right=of b] {$\gamma$};
%
\draw[arr] (a) -- (b);
\draw[arr] (c) -- (b);
\end{tikzpicture}
\end{document}
附录:
在节点半径固定的情况下,需要定义text width
圆:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 0mm and 9mm,
C/.style = {circle, draw, text width=9mm, align=center, inner sep=0pt},
arr/.style = {-Straight Barb, semithick}
]
\node (a) [C] {$\alpha$};
\node (b) [C, right=of a] {$\beta$};
\node (c) [C, right=of b] {$\gamma$};
%
\draw[arr] (a) -- (b);
\draw[arr] (c) -- (b);
\end{tikzpicture}
\end{document}
在您的特定情况下,结果是相同的: