我怎样才能使这个图形适合页面,而不超出边距?

我怎样才能使这个图形适合页面,而不超出边距?

在此处输入图片描述

\documentclass{article}
\usepackage{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
            chains,
            fit,
            positioning,
            quotes}

\begin{document}
\begin{center}
\begin{tikzpicture}[
node distance = 12mm and 12mm,
start chain = going right,
arr/.style = {draw, semithick, rounded    corners, -Straight Barb},
 N/.style = {circle, draw, fill=none, minimum size=1em, 
             outer sep=3pt, font=\tiny},
EN/.style = {N, double, double    distance=1.5pt},
 every edge/.style = {draw, arr},
                ]
% position the nodes a...c
\coordinate[label=left:I] (a);
\node (novoInicial) [N, right=of a] {$q_1$};
\node (b) [N, right=of novoInicial] {$q_2$};
\node (c) [N, above right=of b] {$q_3$};
% position the nodes 8...12
  \begin{scope}[nodes={on chain}]
    \node (d) [N, below right=of c] {$q_8$};
    \foreach \i in {9, 10,...,12}{
        \node (\i) [N] {$q_{\i}$};
    }
\end{scope}
\node (ei) [EN, right=of 12] {$q_{13}$};
\path   
(a) edge (novoInicial)
(novoInicial) edge["$\varepsilon$"] (b)
(b) edge["$\varepsilon$"] (c)
(c) edge["$\varepsilon$"]   (d)
(d) edge["0"]               (9)
(9) edge["$\varepsilon$"]   (10)
(10) edge["0"]               (11)
(11) edge["$\varepsilon$"]   (12)
(12) edge["1"]               (ei)
;
\draw[arr]  (ei) |- ([yshift=45mm] b.north west)
 to ["$\varepsilon$" '] (b.north west);
 %%%%
 \node (j) [N, above right=of c]   {$q_4$};
 \node (k) [N, right=of j] {$q_5$};
 \node (l) [N, right=of k] {$q_6$};
 \node (em) [EN, right=of l] {$q_7$};
 \path   (c) edge["$\varepsilon$"]   (j)
    (j) edge["1"]               (k)
    (k) edge["$\varepsilon$"]   (l)
    (l) edge["0"]               (em);
    \draw[arr]  (em) |- ([yshift=42mm] b.north)
             to ["$\varepsilon$"] (b);
     %%%%
\begin{scope}[nodes={on chain}]
 \node (n) [N, below right=of b] {$q_{14}$};
 \foreach \i in {15, 16,...,18}{
  \node (\i) [N] {$q_{\i}$};
  }
 \end{scope}
  \node (es) [EN, right=of 18] {$q_{19}$};
  \path (b) edge["$\varepsilon$"]   (n)
    (n) edge["0"]               (15)
    (15) edge["$\varepsilon$"]   (16)
    (16) edge["1"]               (17)
    (17) edge["$\varepsilon$"]   (18)
    (18) edge["0"]               (es);
  \draw[arr]  (es) |- ([yshift=-22mm] b.south) to ["$\varepsilon$"] (b);
\end{tikzpicture}
\end{center}
\end{document}

答案1

解决方案#1:减少边距

建议更换 2 号线:

\usepackage[左=1cm, 右=1cm]{几何}

这会缩小页面左右边距,为图片提供更多空间。

解决方案 #2:缩小图片

正如之前评论者所建议的,你可以用类似以下内容替换第 13 行

节点距离 = 5mm 和 5mm,

即使将这些数字从 12 降到 10 也会对间距产生影响。

这些解决方案还可以相互结合使用。

相关内容