如何在 tikz 中创建双圆?

如何在 tikz 中创建双圆?

我想创建一个像这样的圆形(双圆)样式的圆形: 在此处输入图片描述

\tikzset{
    place/.style={
        circle,
        thick,
        draw=black!75,
        fill=white!20,
        minimum size=6mm,
    }
}

如 tikz 所示文档

更新以回应评论:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows,shapes,automata,petri,positioning}
\tikzset{
    old inner xsep/.estore in=\oldinnerxsep,
    old inner ysep/.estore in=\oldinnerysep,
    double circle/.style 2 args={
        circle,
        old inner xsep=\pgfkeysvalueof{/pgf/inner xsep},
        old inner ysep=\pgfkeysvalueof{/pgf/inner ysep},
        /pgf/inner xsep=\oldinnerxsep+#1,
        /pgf/inner ysep=\oldinnerysep+#1,
        alias=sourcenode,
        append after command={
        let     \p1 = (sourcenode.center),
                \p2 = (sourcenode.east),
                \n1 = {\x2-\x1-#1-0.5*\pgflinewidth}
        in
            node [inner sep=0pt, draw, circle, minimum width=2*\n1,at=(\p1),#2] {}
        }
    },
    double circle/.default={2pt}{blue},
    place/.style={
        double circle,
        thick,
        draw=black!75,
        %fill=white!20,
        minimum size=6mm,
    },
    transitionH/.style={
        rectangle,
        thick,
        fill=black,
        minimum width=8mm,
        inner ysep=2pt
    },
    transitionV/.style={
        rectangle,
        thick,
        fill=black,
        minimum height=8mm,
        inner xsep=2pt
    }
}

\begin{document}

\begin{tikzpicture}[node distance=0.4cm and 1cm,>=stealth',bend angle=45,auto]
    \node [place,label=above:$P_1$] (p1) {}
    \node [transitionV,label=above:$T_1$] (t1) [right= of p1] {}
        edge[pre]   (p1);
    \node [place,tokens=1,label=above:$P_2$] (p2) [above right=of t1] {}
        edge[pre]   (t1);
    \node [place,tokens=2,label=above:$P_3$] (p3) [below right=of t1] {}
        edge[pre]   (t1);
    \node [transitionV,label=above:$T_2$] (t2) [above right=of p3] {}
        edge[pre]   (p2)
        edge[pre]   (p3);
    \node [place,tokens=1, label=above:$P_4$] (p4) [above right=of t2] {}
        edge[pre]   (t2);
   \draw[post] (t2.east)  to[out=-30,in=210,overlay,looseness=2.3] (p1); 

\end{tikzpicture}

\end{document}

答案1

将选项添加doubleplace样式并将填充颜色更改为非白色可获得所需的结果:

在此处输入图片描述


你的完整代码还有很多其他内容,然后应该在平均能量损失。在您的完整代码中,您缺少一个 comm 和一个分号 - 这与绘制双圆完全无关。这是将相同代码保持在最低限度的原因之一,这样我们就可以专注于实际问题。

修复这些问题后,代码生成:

在此处输入图片描述

代码:

\documentclass{article}
\usepackage{tikz}

\tikzset{
    place/.style={
        circle, double,
        thick,
        draw=black!75,
        fill=gray!20,
        minimum size=6mm,
    }
}
\begin{document}

\begin{tikzpicture}
    \node[place] at (0,0) {};
\end{tikzpicture}
\end{document}

代码:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows,shapes,automata,petri,positioning}
\tikzset{
    old inner xsep/.estore in=\oldinnerxsep,
    old inner ysep/.estore in=\oldinnerysep,
    double circle/.style 2 args={
        circle,
        old inner xsep=\pgfkeysvalueof{/pgf/inner xsep},
        old inner ysep=\pgfkeysvalueof{/pgf/inner ysep},
        /pgf/inner xsep=\oldinnerxsep+#1,
        /pgf/inner ysep=\oldinnerysep+#1,
        alias=sourcenode,
        append after command={
        let     \p1 = (sourcenode.center),
                \p2 = (sourcenode.east),
                \n1 = {\x2-\x1-#1-0.5*\pgflinewidth}
        in
            node [inner sep=0pt, draw, circle, minimum width=2*\n1,at=(\p1),#2] {}
        }
    },
    double circle/.default={2pt}{blue},
    place/.style={
        double, circle,% <--- missing comma
        thick,
        draw=black!75,
        %fill=white!20,
        minimum size=6mm,
    },
    transitionH/.style={
        rectangle,
        thick,
        fill=black,
        minimum width=8mm,
        inner ysep=2pt
    },
    transitionV/.style={
        rectangle,
        thick,
        fill=black,
        minimum height=8mm,
        inner xsep=2pt
    }
}

\begin{document}

\begin{tikzpicture}[node distance=0.4cm and 1cm,>=stealth',bend angle=45,auto]
    \node [place,label=above:$P_1$] (p1) {};% <---- Missing semi colon
    \node [transitionV,label=above:$T_1$] (t1) [right= of p1] {}
        edge[pre]   (p1);
    \node [place,tokens=1,label=above:$P_2$] (p2) [above right=of t1] {}
        edge[pre]   (t1);
    \node [place,tokens=2,label=above:$P_3$] (p3) [below right=of t1] {}
        edge[pre]   (t1);
    \node [transitionV,label=above:$T_2$] (t2) [above right=of p3] {}
        edge[pre]   (p2)
        edge[pre]   (p3);
    \node [place,tokens=1, label=above:$P_4$] (p4) [above right=of t2] {}
        edge[pre]   (t2);
   \draw[post] (t2.east)  to[out=-30,in=210,overlay,looseness=2.3] (p1); 

\end{tikzpicture}

\end{document}

相关内容