2

I want to create an automaton in tikz and adjust the looseness and bend properties of the edges. If I set the values high, it creates a lot of empty space to the left and below the graphic. In my document, this makes it shift to the right, partially off the page. Here is an mwe.

\documentclass{standalone}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{automata,calc,positioning}
\begin{document}
   \begin{tikzpicture}[
         node distance=3cm,
         clique/.style={fill=SkyBlue},
         font=\sffamily,
         thick,
   ]
      \node[clique,state] (B) {B};
      \node[clique,state,below=of B] (A) {A};
      \node[clique,state] at ($(B) !.5! (A) + (2cm,0)$) (C) {C};
      \node[clique,state,right=of C] (D) {D};
      \node[state,above=of D] (E) {E};
      \node[state,right=of D] (F) {F};
      \node[state,below left=of F] (H) {H};
      \node[state,below=of F] (G) {G};

      \path
      (A) edge[bend left] (E)
      (A) edge[bend right=10] (F)
      (A) edge[bend right] (G)
      (A) edge (D)

      (B) edge[bend right=100,looseness=1.6,out=270] (H)
      (B) edge[bend right=100,looseness=1.6,out=260] (G)
      (B) edge[bend left=100,looseness=1.2] (F)

      (C) edge[bend left=10] (G)
      (C) edge[bend left=20] (F)
      (C) edge[bend right] (H)
      (C) edge (E)

      (D) edge (E)
      (D) edge (F)
      (D) edge (G)


      (E) edge (G)
      (E) edge[bend left=80,looseness=2] (H)
      ;
   \end{tikzpicture}
\end{document}

The result is this:

enter image description here

I would have it trimmed to the actual content, as standalone usually does. What causes this and how do I get rid of it?

oarfish
  • 1,419
  • 1
    Because the control points of the edges are counted into the bounding box of the picture. I'm sure this has been addressed before, but I can't find it now. – yo' Oct 14 '15 at 19:09
  • 2
    Well, makes sense. Perhaps you mean this: http://tex.stackexchange.com/q/43621/31250 – oarfish Oct 14 '15 at 19:13
  • I can try to make a path for the bounding box, but have not figured out out to make it work in a figure. – oarfish Oct 14 '15 at 19:17
  • Doesn't \clip (-3,-3) rectangle (3,3) work for clipping the bounding box? (Sorry I can't test now.) – yo' Oct 14 '15 at 19:29
  • @yo' Yes, it took me a moment, but that solution actually does work. So really, this is a duplicate. – oarfish Oct 14 '15 at 19:31

1 Answers1

3

As mentionend by yo', the extra space is due to the control points which move further from the path when it's curved. I have found this answer which suggests to draw a grid to identify the bounding box

\begin{tikzpicture}
\draw[help lines,step=8pt] (-1.2cm,-4cm) grid (12cm,8cm);
\clip (-1.2cm,-4cm) rectangle (12cm,8cm);
...

In my case, these values were appropriate

oarfish
  • 1,419