TikZ 自循环样式问题

TikZ 自循环样式问题

我有一个关于如何在我的图表中“设计”自循环的样式的问题。

以下是我的序言:

\documentclass[letterpaper]{tufte-handout}

% Additional LaTeX Packages

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}

% LaTeX TikZ Graphics Package

\usepackage{tikz}
\usetikzlibrary{arrows}
\tikzset{
    >=stealth,
    auto,
    node distance=3.5cm,
    font=\scriptsize,
    possible world/.style={circle,draw,thick,align=center},
    real world/.style={double,circle,draw,thick,align=center},
    minimum size=40pt
}

这是我目前尝试绘制的图表:

\begin{figure}
\centering
\begin{tikzpicture}
\node[real world] (1) {$\World_{1}$ \\ $H,L$};
\node[possible world] (2) [right of=1] {$\World_{2}$ \\ $\neg{H},L$};
\node[possible world] (3) [below of=1] {$\World_{3}$ \\ $\neg{H},L$};
\node[possible world] (4) [right of=3] {$\World_{4}$ \\ $\neg{H},L$};
\path[]
    (1) edge [loop above,thick] node {$A,B,C$} (1)
    (2) edge [loop above,thick] node {$A,B,C$} (2)
    (3) edge [loop below,thick] node {$A,B,C$} (3)
    (4) edge [loop below,thick] node {$A,B,C$} (4)
    (1) [<->,thick] edge node[above] {$B$} (2)
    (3) [<->,thick] edge node[below] {$A,B,C$} (4)
    (1) [->,thick] edge node[left] {$C$} (3)
    (1) [->,thick] edge node[right] {$C$} (4)
    (2) [->,thick] edge node[left] {$C$} (3)
    (2) [->,thick] edge node[right] {$C$} (4);
\end{tikzpicture}
\caption{Successor state, $\State_{2}$, obtained after $A$ peeks into the strongbox and learns that the coin is facing heads up without the knowledge of his fellow agents.}
\label{fig:multi-modal-strongbox:peek-2-successor}
\end{figure}

我得到的图片如下所示:

在此处输入图片描述

但我确实希望弧线看起来像这个例子中的那样:

在此处输入图片描述

我不介意标签位于弧线的上方或下方而不是中间,但我感兴趣的是复制自循环的整体形状。

另外,顺便提一下 - 我无法找到增加节点之间水平间距的方法。任何建议都将不胜感激。

答案1

您可以使用库来调整spositioning之间的水平距离。另请注意,这里用 替换,因为前者已被弃用。您可以为 放置四个额外的节点并调整with参数。由于我不知道etc 是什么,我已将它们替换为etc。此外,我在几个地方进行了调整,因为您已经对其进行了全局定义(我通常不会这样做)。noderight of =...right = <dimen>cm of ...A, B, Cedgein=...,out=...\WorldWorldminimum size

完整代码:

\documentclass[letterpaper]{tufte-handout}

% Additional LaTeX Packages

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}

% LaTeX TikZ Graphics Package

\usepackage{tikz}
\usetikzlibrary{arrows,positioning}
\tikzset{
    >=stealth,
    %auto,
    %node distance=3.5cm,
    font=\scriptsize,
    possible world/.style={circle,draw,thick,align=center},
    real world/.style={double,circle,draw,thick,align=center},
    minimum size=40pt
}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\node[real world] (1) {$World_{1}$ \\ $H,L$};
\node[above = .1ex of 1,inner sep = 0pt,outer sep=0pt,minimum size=25pt] (1a) {$A,B,C$};
\node[possible world] (2) [right = 5cm of 1] {$World_{2}$ \\ $\neg{H},L$};
\node[above = .1ex of 2,inner sep = 0pt,outer sep=0pt,minimum size=25pt] (2a) {$A,B,C$};
\node[possible world] (3) [below = 2cm of 1] {$World_{3}$ \\ $\neg{H},L$};
\node[below = .1ex of 3,inner sep = 0pt,outer sep=0pt,minimum size=25pt] (3a) {$A,B,C$};
\node[possible world] (4) [right = 5cm of 3] {$World_{4}$ \\ $\neg{H},L$};
\node[below = .1ex of 4,inner sep = 0pt,outer sep=0pt,minimum size=25pt] (4a) {$A,B,C$};
\path[]
    (1) edge [in=180, out=130,thick] (1a)
    (1a) edge [->,in=50, out=0,thick] (1) 
    (2) edge [in=180, out=130,thick] (2a)
    (2a) edge [->,in=50, out=0,thick]  (2)
    (3) edge [in=180, out=230,thick] (3a)
    (3a) edge [->,in=310, out=0,thick]  (3)
    (4) edge [in=180, out=230,thick] (4a)
    (4a) edge [->,in=310, out=0,thick]  (4)
    (1) [<->,thick] edge node[above,minimum size=0pt] {$B$} (2)
    (3) [<->,thick] edge node[below,minimum size=0pt] {$A,B,C$} (4)
    (1) [->,thick] edge node[left,minimum size=0pt] {$C$} (3)
    (1) [->,thick] edge node[right] {$C$} (4)
    (2) [->,thick] edge node[left] {$C$} (3)
    (2) [->,thick] edge node[right,minimum size=0pt] {$C$} (4);
\end{tikzpicture}
\caption{Successor state, $State_{2}$, obtained after $A$ peeks into the strongbox and learns that the coin is facing heads up without the knowledge of his fellow agents.}
\label{fig:multi-modal-strongbox:peek-2-successor}
\end{figure}
\end{document}

在此处输入图片描述

相关内容