独立的边框选项无法按预期工作

独立的边框选项无法按预期工作

下面的代码

\documentclass[border=1pt]{standalone}

\usepackage{tikz}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{bm}

\usetikzlibrary{automata,positioning}

\begin{document}
    \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 
    \node[state,accepting] (0) {$\bm{0}$};
    \node[state,accepting] (3) [right=of 0] {$\bm{3}$}; 
    \node[state,accepting] (6) [right=of 3] {$\bm{6}$};
    \node[state] (1) [above=of 0] {$\bm{1}$};
    \node[state] (2) [above=of 1] {$\bm{2}$};
    \node[state] (4) [above=of 3] {$\bm{4}$};
    \node[state] (5) [above=of 4] {$\bm{5}$};
    \node[state] (7) [above=of 6] {$\bm{7}$};
    \node[state] (8) [above=of 7] {$\bm{8}$};    
    \path[->] 
    (0) edge [in=170, out=10] node  {$v$} (3)
    (3) edge [in=170, out=10] node  {$v$} (6)
    (6) edge [in=350, out=190] node  {$w$} (3)
    (3) edge [in=350, out=190] node  {$w$} (0)
    (6) edge [in=330, out=210] node [swap,yshift=-1mm] {$v$} (0)
    (0) edge [in=230, out=310] node [yshift=-1mm] {$w$} (6)
    (0) edge [in=280, out=80] node[swap,yshift=-2mm,xshift=-1mm]  {$k$} (1)
    (3) edge [in=280, out=80] node[swap,yshift=-2mm,xshift=-1mm]  {$k$} (4)
    (6) edge [in=280, out=80] node[swap,yshift=-2mm,xshift=-1mm]  {$k$} (7)
    (7) edge [in=280, out=80] node[swap,yshift=-2mm,xshift=-1mm]  {$k$} (8)
    (4) edge [in=280, out=80] node[swap,yshift=-2mm,xshift=-1mm]  {$k$} (5)
    (1) edge [in=280, out=80] node[swap,yshift=-2mm,xshift=-1mm]  {$k$} (2)
    (2) edge [in=100, out=260] node [swap,yshift=3mm,xshift=1mm]  {$m$} (1)
    (5) edge [in=100, out=260] node[swap,yshift=3mm,xshift=1mm]  {$m$} (4)
    (8) edge [in=100, out=260] node[swap,yshift=3mm,xshift=1mm]  {$m$} (7)
    (1) edge [in=100, out=260] node[swap,yshift=3mm,xshift=1mm]  {$e$} (0)
    (4) edge [in=100, out=260] node[swap,yshift=3mm,xshift=1mm]  {$e$} (3)
    (7) edge [in=100, out=260] node[swap,yshift=3mm,xshift=1mm]  {$e$} (6)
    (2) edge [in=125, out=330] node [yshift=14mm,xshift=-8.5mm] {$h$} (3)
    (1) edge [in=150, out=330] node [yshift=7mm,xshift=-6mm] {$h$} (3)
    (2) edge [in=125, out=330] node [yshift=14mm,xshift=-8.5mm] {$h$} (3)
    (5) edge [in=125, out=330] node [yshift=14mm,xshift=-8.5mm] {$h$} (6)
    (2) edge [in=125, out=330] node [yshift=14mm,xshift=-8.5mm] {$h$} (3)
    (4) edge [in=150, out=330] node [yshift=7mm,xshift=-6mm] {$h$} (6)
    (5) edge [in=55, out=220] node [yshift=19.5mm,xshift=4mm] {$l$} (0)
    (8) edge [in=55, out=220] node [yshift=19.5mm,xshift=4mm] {$l$} (3)
    (4) edge [in=30, out=210] node [yshift=12mm,xshift=3mm] {$l$} (0)
    (1) edge [in=30, out=210, color=blue] node [yshift=7mm,xshift=-28mm] {$l$} (6)
    (2) edge [in=20, out=210, color=blue] node [yshift=18mm,xshift=-28mm] {$l$} (6)
    (8) edge [in=120, out=150, color=red, looseness=1.9] node [yshift=4.5mm,xshift=38mm] {$h$} (0)
    (7) edge [in=135, out=60, color=red, looseness=3.5] node [yshift=-26mm,xshift=29mm] {$h$} (0);    
    \end{tikzpicture}
\end{document}  

收益

在此处输入图片描述

状态机周围有很多不需要的空白空间。

为什么这个选项border=1pt不起作用standalone

答案1

如果没有其他解决方案,这可能会有所帮助:

\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 
\useasboundingbox (-2,-1.5) rectangle (5,6);    

在此处输入图片描述

相关内容