使用 TikZ 进行彭罗斯图形符号

使用 TikZ 进行彭罗斯图形符号

如何使用 TikZ 绘制这样的张量网络? 在此处输入图片描述

或许可以添加一些文字。

在此处输入图片描述

我对 LaTeX 非常熟悉,但对 TikZ 还是个菜鸟。我会广泛地绘制这些形状,并希望知道它们的模板。谢谢!

编辑

这是我目前所做的。我不确定如何在指定边界处连接线,放置节点的正确方法(相对位置还是坐标?),以及如何将标记放在指定位置。

\documentclass[tikz,multi,border=10pt]{standalone}
\usetikzlibrary{shapes.geometric,positioning}
\begin{document}
\begin{tikzpicture}
[
    triangle/.style = {regular polygon, regular polygon sides=3, draw=black, fill=green!60!black, inner sep=0pt, minimum size=2cm},
    border rotated/.style = {shape border rotate=180},
    rectangular/.style={fill=brown!80!black, rectangle, rounded corners = 5pt, draw=black, inner sep=0pt, minimum width=4.5cm, minimum height=1cm},
    square/.style={fill=blue!60!black, rectangle, draw=black, inner sep=0pt, minimum size = 1cm}
]

    \node[square] (1) {};
    \node[triangle, border rotated] (2) [below left = 1cm  of 1] {};
    \node[triangle, border rotated] (3) [below right = 1cm  of 1] {};
    \node[rectangular] (4) [below=3cm of 1] {};
    \node[square] (7) [below = 7cm of 1]{};
    \node[triangle] (5) [above left = 1cm  of 7] {};
    \node[triangle] (6) [above right = 1cm  of 7]{};

    \draw (2.35) -- +(0,0.2) -- (1);
    \draw (2.145) to [bend right=45] (5.215);
    \draw (3.145) -- +(0,0.2) -- (1);

\end{tikzpicture}
\end{document}

答案1

我不太确定我是否理解了您问到的所有 3 点。例如,我不确定“token”指的是什么,但我猜是实心的黑色圆圈。

一般来说,相对定位使以后修改代码更加容易。例如,更容易将新内容添加到图表中并让其他内容自动调整。但这实际上是一个在特定情况下哪种方法最有效的问题。通常,绝对定位对于一次性操作来说速度更快,例如,尽管它会使代码的灵活性降低。

我已将其重命名triangletriangular避免覆盖triangle形状。

下面的代码展示了一种方法:

  • 从适当的点连接三角形;
  • 将三角形与矩形从适当的点连接起来;
  • 在矩形中添加黑色圆圈;
  • 添加带有标签的弯曲箭头s'

希望这能让您在现有的基础上进一步发展。

\documentclass[tikz,multi,border=10pt]{standalone}
\usetikzlibrary{shapes.geometric,positioning}
\begin{document}
\begin{tikzpicture}
[
    triangular/.style = {regular polygon, regular polygon sides=3, draw=black, fill=green!60!black, inner sep=0pt, minimum size=2cm},
    border rotated/.style = {shape border rotate=180},
    rectangular/.style={fill=brown!80!black, rectangle, rounded corners = 5pt, draw=black, inner sep=0pt, minimum width=4.5cm, minimum height=1cm},
    square/.style={fill=blue!60!black, rectangle, draw=black, inner sep=0pt, minimum size = 1cm}
]

    \node[square] (1) {};
    \node[triangular, border rotated] (2) [below left = 1cm  of 1] {};
    \node[triangular, border rotated] (3) [below right = 1cm  of 1] {};
    \node[rectangular] (4) [below=3cm of 1] {};
    \node[square] (7) [below = 7cm of 1]{};
    \node[triangular] (5) [above left = 1cm  of 7] {};
    \node[triangular] (6) [above right = 1cm  of 7]{};

    \draw (2.35) -- +(0,0.2) -- (1);
    \draw (2.145) .. controls +(-7.5mm,35mm) and +(-7.5mm,-35mm) .. (5.215);
    \draw (3.145) -- +(0,0.2) -- (1);
    \draw (5.-35) -- +(0,-0.2) -- (7);
    \draw (6.-145) -- +(0,-0.2) -- (7);
    \draw (3.35) .. controls +(7.5mm,35mm) and +(7.5mm,-35mm) .. (6.-35);
    \draw (2.south) -- (4.north -| 2.south) (3.south) -- (4.north -| 3.south) (4.south -| 5.north) -- (5.north) (4.south -| 6.north) -- (6.north);

    \path (2.south) -- node [fill, circle] {} (5.north);
    \path (3.south) -- node [fill, circle] {} (6.north);
    \draw [<-] (4.north west) [bend right] to ++(-10mm,10mm) node [anchor=south] {$s'$};

\end{tikzpicture}
\end{document}

連接

相关内容