I have the following TikZ picture:



\begin{tikzpicture}[initial text={}, auto, >=stealth', node distance=0.75cm]
  \tikzstyle{every edge}=[->, draw]
  \node[state, initial] (i) {$q_0$};
  \node[state, right=of i] (0) {$0$};
  \node[state, right=of 0] (134) {$1, 3, 4$};
  \node[state, right=of 134] (25) {$2, 5$};
  \node[state, right=of 25] (13) {$1, 3$};
  \node[state, below=of 13] (2) {$2$};
  \node[state, below=of 25] (6) {$6$};
  \node[state, below=of 0] (es) {$\emptyset$};
  \node[state, accepting, right=of 13] (f) {$q_1$};

  \path (i) edge node {$1$} (0);
  \path (i) edge[bend left=60] node[above, pos=0.2] {$1$} (f);
  \path (0) edge node {$a$} (134);
  \path (0) edge node {$b$} (es);
  \path (0) edge[bend left=45] node {$1$} (f);
  \path (134) edge[loop below] node[above] {$a$} (134);
  \path (134) edge node {$b$} (25);
  \path (25) edge node {$a$} (13);
  \path (25) edge node {$b$} (6);
  \path (25) edge[bend left] node {$1$} (f);
  \path (13) edge[bend right=45] node {$a$} (134);
  \path (13) edge node {$b$} (2);
  \path (2) edge[bend left] node {$a$} (13);
  \path (2) edge[bend left] node[above] {$b$} (es);
  \path (2) edge node[pos=0.75] {$1$} (f);
  \path (6) edge node {$a$} (134);
  \path (6) edge node {$b$} (es);
  \path (es) edge[loop left] node {$a, b$} (es);
  \path (es) edge[bend right=70] node[pos=0.1, below] {$1$} (f);

Unfortunately, TikZ generates a lot of whitespace above and below the picture, which I want to get rid of. I figured out that it is related to the edges \path (i) edge[bend left=60] node[above, pos=0.2] {$1$} (f); and \path (es) edge[bend right=70] node[pos=0.1, below] {$1$} (f); as the space changes when the values bend ...=## are changed. It seems likely that TikZ reserves space for the label nodes, which, however, is not necessary since the nodes are not in their default position.

Now for my question: what causes this behavior and how can I get rid of it?

  • 1
    Possible solution: tex.stackexchange.com/a/57486/1952 – Ignasi Nov 20 '15 at 8:19
  • @Ignasi: This seems to require a lot of manual fiddling, which I would like to avoid. – JPW Nov 20 '15 at 12:57
  • I thought for a moment than replacing the bend commands with something like (for the (es) path) \path (es) edge[out=305,in=265] node[pos=0.1, below] {$1$} (f); could solve your (interesting) problem, but it didn't. Unfortunately, I think that manual fiddling is unavoidable… – Clément Nov 21 '15 at 6:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.