![使用 TikZ 箭头指示两张图片之间的循环--缺少箭头](https://linux22.com/image/287277/%E4%BD%BF%E7%94%A8%20TikZ%20%E7%AE%AD%E5%A4%B4%E6%8C%87%E7%A4%BA%E4%B8%A4%E5%BC%A0%E5%9B%BE%E7%89%87%E4%B9%8B%E9%97%B4%E7%9A%84%E5%BE%AA%E7%8E%AF--%E7%BC%BA%E5%B0%91%E7%AE%AD%E5%A4%B4.png)
我正在尝试绘制两个箭头,它们应该表示神经网络在两个状态之间循环。按照 Petri 网教程,我使用 pgfonlayer、fit 和范围将两个网络并排对齐。但是,出于某种原因,我无法让箭头出现。以下是代码
\begin{tikzpicture}[auto]
\node[excited] (middle) {-2.5};
\node[inhibited] (west) [left=of middle] {0.5}
edge node {-1} (middle);
\node[inhibited] (east) [right=of middle] {0.5}
edge node {-1} (middle);
\node[excited] (north) [above=of middle] {0.5}
edge node {1} (east)
edge node[swap] {1} (west)
edge node {-1} (middle);
\node[excited] (south) [below=of middle] {0.5}
edge node {-1} (middle)
edge node {1} (west)
edge node [swap] {1} (east);
\begin{scope}[xshift=6cm]
\node[excited] (middle1) {-2.5};
\node[excited] (west1) [left=of middle1] {0.5}
edge node {-1} (middle1);
\node[excited] (east1) [right=of middle1] {0.5}
edge node {-1} (middle1);
\node[inhibited] (north1) [above=of middle1] {0.5}
edge node {1} (east1)
edge node[swap] {1} (west1)
edge node {-1} (middle1);
\node[inhibited] (south1) [below=of middle1] {0.5}
edge node {-1} (middle1)
edge node {1} (west1)
edge node [swap] {1} (east1);
\end{scope}
\begin{pgfonlayer}{background}
\node (n1) [fit=(west) (middle) (east) (south) (north)] {};
\node (n2) [fit=(west1) (middle1) (east1) (south1) (north1)] {};
\draw [shorten >=5mm,shorten <=5mm,bend left=45,<-]
(north) to (north1);
\draw [shorten >=5mm,shorten <=5mm,bend right=45,->]
(south) to (south1);
\end{pgfonlayer}
\end{tikzpicture}
而结果,无论我是否<-
在命令->
中\draw
。
有人知道为什么会发生这种情况吗?
谢谢您的帮助。
答案1
这就是你想要的吗?你的代码不完整,这个解决方案添加了一些代码以获得你发布的输出。
代码
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,intersections,calc,fit}
\tikzset{
excited/.style={circle,thick,draw=black,fill=blue!50,minimum size=6mm},
inhibited/.style={circle,thick,draw,fill=none,minimum size=6mm},
every fit/.append style=text badly centered % to get rid of underfull bad box
}
\begin{document}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\begin{tikzpicture}[auto]
\node[excited] (middle) {-2.5};
\node[inhibited] (west) [left=of middle] {0.5}
edge node {-1} (middle);
\node[inhibited] (east) [right=of middle] {0.5}
edge node {-1} (middle);
\node[excited] (north) [above=of middle] {0.5}
edge node {1} (east)
edge node[swap] {1} (west)
edge node {-1} (middle);
\node[excited] (south) [below=of middle] {0.5}
edge node {-1} (middle)
edge node {1} (west)
edge node [swap] {1} (east);
\begin{scope}[xshift=6cm]
\node[excited] (middle1) {-2.5};
\node[excited] (west1) [left=of middle1] {0.5}
edge node {-1} (middle1);
\node[excited] (east1) [right=of middle1] {0.5}
edge node {-1} (middle1);
\node[inhibited] (north1) [above=of middle1] {0.5}
edge node {1} (east1)
edge node[swap] {1} (west1)
edge node {-1} (middle1);
\node[inhibited] (south1) [below=of middle1] {0.5}
edge node {-1} (middle1)
edge node {1} (west1)
edge node [swap] {1} (east1);
\end{scope}
\begin{pgfonlayer}{background}
\node (n1) [fit=(west) (middle) (east) (south) (north)] {};
\node (n2) [fit=(west1) (middle1) (east1) (south1) (north1)] {};
\draw [shorten >=5mm,shorten <=5mm,bend left=45,<-]
(north) to (north1);
\draw [shorten >=5mm,shorten <=5mm,bend right=45,->]
(south) to (south1);
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
答案2
我决定将此作为答案,因为如果其他人使用与我相同的 PDF 查看器(evince),他们可能会遇到同样的问题。
我注意到,当我在 Chrome 中查看 PDF 时,箭头会出现。在 100% 缩放时,没有箭头。如果我放大到大约 250%,它们就会出现。我不确定为什么会发生这种情况,但如果其他人遇到这个问题,好吧;这不是什么大问题。