tikz 中的弯曲箭头

tikz 中的弯曲箭头

我想创建一个图形模型(有点像贝叶斯网络),其中一些箭头是弯曲的。我正在使用 tikz 包。

这是代码:

\documentclass{article}

\usepackage{tikz}
\usepackage{tkz-graph}  
\usetikzlibrary{bayesnet}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{trees}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows.meta}
\tikzset{>={Latex[width=3mm,length=3mm]}}

\begin{document}

\begin{figure}
\begin{center}
\tikz{ %
\node[obs] (C) {C} ; %
\node[obs, right=of C] (M1) {M1} ; %
\node[obs, right=of M1] (M2) {M2} ; %
\node[obs, right=of M2] (E) {E} ; %
\node[ellipse, latent, above=1.5] (Mechanism) {Mechanism} ; %
\edge {C} {M1} ; %
\edge {M1} {M2} ; %
\edge {M2} {E} ; %
\edge[dashed, bend right] {Mechanism} {C}
\edge[dashed, bend right] {Mechanism} {M1}
\edge[dashed, bend left] {Mechanism} {M2}
\edge[dashed, bend left] {Mechanism} {E}
 } 
\tikz{ %
\node[obs] (C) {C} ; %
\node[obs, right=of C, yshift=1.25cm] (E1) {E1} ; %
\node[obs, right=of C] (E2) {E2} ; %
\node[obs, right=of C, yshift=-1.25cm] (E3) {E3} ; %
\node[ellipse, latent, above=1.5] (Mechanism) {Mechanism} ; %
\edge {C} {E1} ; %
\edge {C} {E2} ; %
\edge {C} {E3} ; %
\edge[dashed, bend right] {Mechanism} {C} ;%
\edge[dashed, bend left] {Mechanism} {E1} ;%
\edge[dashed, bend right] {Mechanism} {E2} ;%
\edge[dashed, out = 200, in = 270] {Mechanism} {E3} ;
 } 
 \tikz{ %
\node[obs] (E) {E} ; %
\node[obs, left=of E, yshift=1.25cm] (C1) {C1} ; %
\node[obs, left=of E] (C2) {C2} ; %
\node[obs, left=of E, yshift=-1.25cm] (C3) {C3} ; %
\node[ellipse, latent, above=1.5] (Mechanism) {Mechanism} ; %
\edge {C1} {E} ; %
\edge {C2} {E} ; %
\edge {C3} {E} ; %
\edge[dashed, bend right] {Mechanism} {C1} ;%
\edge[dashed, bend left] {Mechanism} {C2} ;%
\edge[dashed, out = 180, in =180] {Mechanism} {C3} ;%
\edge[dashed, bend left] {Mechanism} {E} ;
}
 \caption{blah}
 \label{fig:mechanism}
\end{center}
\end{figure}

\end{document}

这段代码之前生成了如下内容:

我希望它看起来像什么

然而,我最近升级了我的 LaTeX 编辑器(Texpad),现在由于某种原因,弯曲的虚线边缘变成了直的:

不是我想要的样子

有人知道如何解决这个问题吗?

答案1

问题出在语法上:

在此处输入图片描述

\documentclass{article}

\usepackage{tikz}
\usepackage{tkz-graph}  
\usetikzlibrary{bayesnet}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{trees}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows.meta}
\tikzset{>={Latex[width=3mm,length=3mm]}}
\pagestyle{empty}
\begin{document}

\begin{figure}
\begin{center}
\begin{tikzpicture}


\node[obs] (C) {C} ; %
\node[obs, right=of C] (M1) {M1} ; %
\node[obs, right=of M1] (M2) {M2} ; %
\node[obs, right=of M2] (E) {E} ; %
\node[ellipse, latent, above=1.5] (Mechanism) {Mechanism} ; %
\edge {C} {M1} ; %
\edge {M1} {M2} ; %
\edge {M2} {E} ; %

\foreach \x/\y in {C/right,M1/right,M2/left,E/left}
\path (Mechanism) edge [dashed, bend \y,->]  (\x) ;
\end{tikzpicture}


\begin{tikzpicture}[->]
\node[obs] (C) {C} ; %
\node[obs, right=of C, yshift=1.25cm] (E1) {E1} ; %
\node[obs, right=of C] (E2) {E2} ; %
\node[obs, right=of C, yshift=-1.25cm] (E3) {E3} ; %
\node[ellipse, latent, above=1.5] (Mechanism) {Mechanism} ; %
\edge {C} {E1} ; %
\edge {C} {E2} ; %
\edge {C} {E3} ; %
\path (Mechanism) edge[dashed, bend right]  (C) ;%
\path (Mechanism) edge[dashed, bend left] (E1) ;%
\path (Mechanism) edge[dashed, bend right] (E2) ;%
\path (Mechanism) edge[dashed, out = 200, in = 270] (E3) ;

\end{tikzpicture}

\begin{tikzpicture}[->]
\node[obs] (E) {E} ; %
\node[obs, left=of E, yshift=1.25cm] (C1) {C1} ; %
\node[obs, left=of E] (C2) {C2} ; %
\node[obs, left=of E, yshift=-1.25cm] (C3) {C3} ; %
\node[ellipse, latent, above=1.5] (Mechanism) {Mechanism} ; %
\edge {C1} {E} ; %
\edge {C2} {E} ; %
\edge {C3} {E} ; %
\path (Mechanism) edge[dashed, bend right]  (C) ;%
\path (Mechanism) edge[dashed, bend left] (C2) ;%
\path (Mechanism) edge[dashed, out = 180, in =180] (C3) ;%
\path (Mechanism) edge[dashed, bend left] (E) ;

\end{tikzpicture}

 \caption{blah}
 \label{fig:mechanism}
\end{center}
\end{figure}

\end{document}

相关内容