我如何创建看起来像这样的图表?

我如何创建看起来像这样的图表?

所以我需要在作业里放一些图表。我已经在纸上画了一些,但我就是无法把它们放到 latex 中。有谁知道我如何才能把看起来像这样的图表放到 .tex 文件中。在此处输入图片描述

我希望能够自行确定箭头指向何处等。我也只需要 4 个节点(a、b、c 和 d)。如何在 texmaker 中执行此操作?

任何帮助都将受到赞赏。

答案1

psmatrix可以使用来自的环境轻松  pst-node制作此类图表。循环是使用以下命令获得的\nccircle,该命令将节点逆时针链接到自身:

\documentclass[border=5pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pst-node, pst-arrow, auto-pst-pdf}%

\begin{document}

\sffamily
\def\psrowhooki{\hskip 4em}
\begin{psmatrix}[rowsep=1.2cm, colsep=1.2cm]
  [name=a] a & [name=c] c \\
  [name=b] b & [name=d] d & [name=e] e \\
  %%%%% Arrows
  \psset{nodesep=6pt, shortput =nab, arrows=->, arrowinset=0.12, arcangle=20}%
  \nccircle[angle=80,]{<-}{a}{0.4cm}
  \nccircle[angle=120]{b}{0.4cm}
  \nccircle[angle=-40]{<-}{c}{0.4cm}
  \nccircle[angle=120]{d}{0.45cm}
  \nccircle[angle=-110]{<-}{e}{0.4cm}
  \ncarc{c}{d}
  \ncarc{d}{c}%
  \ncline{d}{e}
\end{psmatrix}

\end{document} 

在此处输入图片描述

答案2


在此处输入图片描述

答案3

如果你想制作一个有限状态机(比如 DFA),可以使用位于http://madebyevan.com/fsm/. 它输出使用该包的 LaTeX tikz

你的例子是:

\documentclass[12pt]{article}
\usepackage{tikz}

\begin{document}

\begin{center}
\begin{tikzpicture}[scale=0.2]
\tikzstyle{every node}+=[inner sep=0pt]
\draw [black] (25.3,-12.8) circle (3);
\draw (25.3,-12.8) node {$a$};
\draw [black] (20.6,-26.9) circle (3);
\draw (20.6,-26.9) node {$b$};
\draw [black] (51,-13.4) circle (3);
\draw (51,-13.4) node {$c$};
\draw [black] (45.4,-28.1) circle (3);
\draw (45.4,-28.1) node {$d$};
\draw [black] (63.1,-26.9) circle (3);
\draw (63.1,-26.9) node {$e$};
\draw [black] (23.144,-10.731) arc (253.92142:-34.07858:2.25);
\fill [black] (25.63,-9.83) -- (26.33,-9.2) -- (25.37,-8.92);
\draw [black] (19.493,-29.676) arc (5.98721:-282.01279:2.25);
\fill [black] (17.72,-27.71) -- (16.88,-27.3) -- (16.98,-28.29);
\draw [black] (48.39,-27.9) -- (60.11,-27.1);
\fill [black] (60.11,-27.1) -- (59.27,-26.66) -- (59.34,-27.66);
\draw [black] (66.077,-26.639) arc (122.74949:-165.25051:2.25);
\fill [black] (65.12,-29.1) -- (65.13,-30.05) -- (65.97,-29.51);
\draw [black] (44.011,-30.746) arc (0.02737:-287.97263:2.25);
\fill [black] (42.45,-28.61) -- (41.65,-28.11) -- (41.66,-29.11);
\draw [black] (51.016,-10.412) arc (207.43495:-80.56505:2.25);
\fill [black] (53.38,-11.59) -- (54.32,-11.67) -- (53.86,-10.78);
\draw [black] (44.931,-25.143) arc (-177.46822:-224.2407:13.275);
\fill [black] (44.93,-25.14) -- (45.4,-24.32) -- (44.4,-24.37);
\draw [black] (50.753,-16.388) arc (-8.43582:-33.27309:23.182);
\fill [black] (50.75,-16.39) -- (50.14,-17.11) -- (51.13,-17.25);
\end{tikzpicture}
\end{center}

\end{document}

输出如下: 有限状态机示例

答案4

使用tikz matrix

\documentclass[border=1cm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{matrix, arrows.meta, bending}

\begin{document}
\begin{tikzpicture}[>=Latex]
    \matrix[
        column sep=0pt,
        row sep=7ex,
        matrix of nodes,
        ] (m) {
    &|(a)| a &[3em]& |(c)| c &[3em]\\
    |(b)| b && |(d)| d && |(e)| e \\
        };
    \draw[->] (a.south west) arc (290:10:1em);
    \draw[->] (b.north west) arc (-290:-30:1em);
    \draw[->] (c.north west) arc (180:-80:1em);
    \draw[->] (d.north west) arc (-270:-30:1em);
    \draw[->] (e.north east) arc (120:-160:1em);    
    \draw[->] (d) -- (e); 
    \draw[->] (d) to[bend left] (c); 
    \draw[->] (c) to[bend left] (d); 
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容