如何在 tikzpicture 中制作一个相对较大的 NFA?

如何在 tikzpicture 中制作一个相对较大的 NFA?

我正在尝试构建的机器将有 15 种状态,当我编译时,这些状态开始在页面上运行。

\documentclass{article}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\usepackage{float}

\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}
\usepackage{tikz}
\usetikzlibrary{automata, positioning, arrows}
\tikzset{
    ->, % makes the edges directed
    %>=stealth’, % makes the arrow heads bold
    node distance=3cm, % specifies the minimum distance between two nodes. Change if necessary.
    every state/.style={thick, fill=gray!10}, % sets the properties for each ’state’ node
    initial text=$ $, % sets the text that appears on the start arrow
}
\begin{document}
    \begin{figure}[H]
    1.19 a
    %\centering
    \begin{tikzpicture}
        \node[state, initial](1) {};
        \node[state, right of=1](2){};
        \node[state, above right of=2](3){};
        \node[state, right of=3](4) {};
        \node[state, below right of=2](5){};
        \node[state, right of=5](6){};
        \node[state, below right of=4](7){};
        \node[state,right of=7](8){};
        \node[state,right of=8](9){};
        \node[state,right of=9](10){};
    \end{tikzpicture}
    \end{figure}
\end{document}

答案1

您已经加载positioning,因此您可能想要使用它。“使用它”意味着代替right of=right=ofright=<distance> of,并且类似地abovebelowleft。使图表变小就像设置一个不太大的 一样简单node distance

\documentclass{article}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{automata, positioning, arrows}
\tikzset{
    ->, % makes the edges directed
    %>=stealth', % makes the arrow heads bold
    node distance=3cm, % specifies the minimum distance between two nodes. Change if necessary.
    every state/.style={thick, fill=gray!10}, % sets the properties for each 'state' node
    initial text=$ $, % sets the text that appears on the start arrow
}
\begin{document}
    \begin{figure}[H]
    \centering
    \begin{tikzpicture}[node distance=2em]
        \node[state, initial](1) {};
        \node[state, right=of 1](2){};
        \node[state, above right=of 2](3){};
        \node[state, right=of 3](4) {};
        \node[state, below right=of 2](5){};
        \node[state, right=of 5](6){};
        \node[state, below right=of 4](7){};
        \node[state,right=of 7](8){};
        \node[state,right=of 8](9){};
        \node[state,right=of 9](10){};
    \end{tikzpicture}
    \end{figure}
\end{document}

在此处输入图片描述

还请考虑不使用该float包,而arrows.meta使用arrows

相关内容