4

I'm trying to dot2tex to render automata. For reasons I do not understand, the rendering is missing some boxes.

For the following Dot file input:

digraph
{
  rankdir = LR
  {
    I0 [shape = point, width = 0]
    F4 [shape = point, width = 0]
  }
  {
    0 [label = "a((a+b) : b^* :  c)", texmode = math, shape = box ]
    1 [label = "(a+b):b^*:c"        , texmode = math, shape = box ]
    2 [label = "b^*:c"              , texmode = math, shape = box ]
    3 [label = "(a+b):b^*"          , texmode = math, shape = box ]
    4 [label = "b^*"                , texmode = math, shape = box ]
  }
  edge [texmode = math]
  I0 -> 0
  0 -> 1 [label = "a"]
  1 -> 1 [label = "b"]
  1 -> 2 [label = "a, b"]
  1 -> 3 [label = "c"]
  2 -> 2 [label = "b"]
  2 -> 4 [label = "c"]
  3 -> 3 [label = "b"]
  3 -> 4 [label = "a, b"]
  4 -> F4
  4 -> 4 [label = "b"]
}

Using dot2tex --crop --nominsize --autosize --usepdflatex ex.dot > ex.tex && texi2dvi --pdf ex.tex to compile, I don't have a single box displayed at all in the generated PDF:

enter image description here

As demanded, this is the generated LaTeX file:

\documentclass{article}
\usepackage[x11names, rgb]{xcolor}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{snakes,arrows,shapes}
\usepackage{amsmath}
%
%

\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{0pt}%

%

\begin{document}
\pagestyle{empty}
%
%
%

\enlargethispage{100cm}
% Start of code
% \begin{tikzpicture}[anchor=mid,>=latex',line join=bevel,]
\begin{tikzpicture}[>=latex',line join=bevel,]
  \pgfsetlinewidth{1bp}
%%
\begin{scope}
  \pgfsetstrokecolor{black}
  \definecolor{strokecol}{rgb}{1.0,1.0,1.0};
  \pgfsetstrokecolor{strokecol}
  \definecolor{fillcol}{rgb}{1.0,1.0,1.0};
  \pgfsetfillcolor{fillcol}
\end{scope}
\begin{scope}
  \pgfsetstrokecolor{black}
  \definecolor{strokecol}{rgb}{1.0,1.0,1.0};
  \pgfsetstrokecolor{strokecol}
  \definecolor{fillcol}{rgb}{1.0,1.0,1.0};
  \pgfsetfillcolor{fillcol}
\end{scope}
  \pgfsetcolor{black}
  % Edge: 1 -> 1
  \draw [->] (236.33bp,68.032bp) .. controls (232.73bp,77.033bp) and (236.41bp,86bp)  .. (247.37bp,86bp) .. controls (254.05bp,86bp) and (258.02bp,82.67bp)  .. (258.41bp,68.032bp);
  \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
  \pgfsetstrokecolor{strokecol}
  \draw (247.37bp,95bp) node {$b$};
  % Edge: 2 -> 2
  \draw [->] (374.7bp,100.02bp) .. controls (370.35bp,108.81bp) and (373.74bp,118bp)  .. (384.87bp,118bp) .. controls (391.65bp,118bp) and (395.56bp,114.59bp)  .. (395.04bp,100.02bp);
  \draw (384.87bp,127bp) node {$b$};
  % Edge: 4 -> 4
  \draw [->] (491.47bp,65.023bp) .. controls (489.16bp,73.814bp) and (490.96bp,83bp)  .. (496.87bp,83bp) .. controls (500.38bp,83bp) and (502.44bp,79.762bp)  .. (502.27bp,65.023bp);
  \draw (496.87bp,92bp) node {$b$};
  % Edge: 1 -> 3
  \draw [->] (287.93bp,42.947bp) .. controls (304.38bp,37.725bp) and (323.54bp,31.646bp)  .. (350bp,23.248bp);
  \draw (319.37bp,44.5bp) node {$c$};
  % Edge: 4 -> F4
  \draw [->] (512.68bp,54.5bp) .. controls (520.55bp,54.5bp) and (530.34bp,54.5bp)  .. (549.15bp,54.5bp);
  % Edge: I0 -> 0
  \draw [->] (21.657bp,55.5bp) .. controls (28.347bp,55.5bp) and (37.759bp,55.5bp)  .. (58.115bp,55.5bp);
  % Edge: 3 -> 3
  \draw [->] (374.16bp,25.032bp) .. controls (370.67bp,34.033bp) and (374.24bp,43bp)  .. (384.87bp,43bp) .. controls (391.34bp,43bp) and (395.2bp,39.67bp)  .. (395.58bp,25.032bp);
  \draw (384.87bp,52bp) node {$b$};
  % Edge: 0 -> 1
  \draw [->] (153.71bp,55.5bp) .. controls (167.21bp,55.5bp) and (181.99bp,55.5bp)  .. (205.95bp,55.5bp);
  \draw (179.87bp,63.5bp) node {$a$};
  % Edge: 3 -> 4
  \draw [->] (419.6bp,24.191bp) .. controls (433.26bp,29.053bp) and (449.13bp,34.869bp)  .. (463.37bp,40.5bp) .. controls (466.1bp,41.581bp) and (468.95bp,42.746bp)  .. (481.06bp,47.899bp);
  \draw (450.37bp,50.5bp) node {$a, b$};
  % Edge: 1 -> 2
  \draw [->] (288.66bp,65.609bp) .. controls (309.19bp,70.762bp) and (333.78bp,76.932bp)  .. (362.78bp,84.207bp);
  \draw (319.37bp,86.5bp) node {$a, b$};
  % Edge: 2 -> 4
  \draw [->] (407.08bp,82.752bp) .. controls (425.49bp,76.892bp) and (452.16bp,68.406bp)  .. (481.06bp,59.211bp);
  \draw (450.37bp,80.5bp) node {$c$};
  % Node: F4
\begin{scope}
  \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
  \pgfsetstrokecolor{strokecol}
  \definecolor{fillcol}{rgb}{0.0,0.0,0.0};
  \pgfsetfillcolor{fillcol}
\end{scope}
  % Node: I0
\begin{scope}
  \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
  \pgfsetstrokecolor{strokecol}
  \definecolor{fillcol}{rgb}{0.0,0.0,0.0};
  \pgfsetfillcolor{fillcol}
\end{scope}
  % Node: 1
\begin{scope}
  \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
  \pgfsetstrokecolor{strokecol}
  \draw (247.37bp,55.5bp) node {$(a+b):b^*:c$};
\end{scope}
  % Node: 0
\begin{scope}
  \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
  \pgfsetstrokecolor{strokecol}
  \draw (105.87bp,55.5bp) node {$a((a+b) : b^* :  c)$};
\end{scope}
  % Node: 3
\begin{scope}
  \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
  \pgfsetstrokecolor{strokecol}
  \draw (384.87bp,12.5bp) node {$(a+b):b^*$};
\end{scope}
  % Node: 2
\begin{scope}
  \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
  \pgfsetstrokecolor{strokecol}
  \draw (384.87bp,89.5bp) node {$b^*:c$};
\end{scope}
  % Node: 4
\begin{scope}
  \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
  \pgfsetstrokecolor{strokecol}
  \draw (496.87bp,54.5bp) node {$b^*$};
\end{scope}
%
\end{tikzpicture}
% End of code

%
\end{document}
%

If I comment the definition of nodes I0 and F4, then I get some boxes, but not all of them! I would prefer rounded boxes, but that does not seem to work properly either.

digraph
{
  rankdir = LR
  {
    node [shape = point, width = 0]
    I0
    F4
  }
  {
    node [texmode = math, shape = box, style = rounded]
    0 [label = "a((a+b) : b^* :  c)"]
    1 [label = "(a+b):b^*:c"]
    2 [label = "b^*:c"]
    3 [label = "(a+b):b^*"]
    4 [label = "b^*"]
  }
  edge [texmode = math]
  I0 -> 0
  0 -> 1 [label = "a"]
  1 -> 1 [label = "b"]
  1 -> 2 [label = "a, b"]
  1 -> 3 [label = "c"]
  2 -> 2 [label = "b"]
  2 -> 4 [label = "c"]
  3 -> 3 [label = "b"]
  3 -> 4 [label = "a, b"]
  4 -> F4
  4 -> 4 [label = "b"]
}

I've read the doc, and found nothing interesting. Same problem with tikz output. I looked at the xdot output, and it does output the boxes, the problem seems to come from dot2tex. I've read the --debug logs, and saw nothing fishy.

Is there something I missed?

Thanks in advance!

style has too many meaning (EDIT)

Well, it appears that I was using "style" as Graphviz expects it; however it is also interpreted by dot2tex as TikZ style to apply to the node. That might be why I was getting weird results.

Further experience led me to the following Dot input file:

digraph
{
  d2tdocpreamble = "
    \usetikzlibrary{arrows, automata, positioning}
    \tikzstyle{automaton}=[shorten >=1pt, pos=.4, >=stealth', initial text=]
    \tikzstyle{state}=[rectangle, rounded corners]
    \tikzstyle{accepting}=[accepting by arrow]
  "
  rankdir = LR
  {
    node [texmode = "math", style = "state"]
    0 [label = "a((a+b) : b^* :  c)", style = "state, initial"]
    1 [label = "(a+b):b^*:c"]
    2 [label = "b^*:c"]
    3 [label = "(a+b):b^*"]
    4 [label = "b^*", style = "state, accepting"]
  }
  edge [texmode = "math", lblstyle = auto]
  0 -> 1 [label = "a"]
  1 -> 1 [label = "b"]
  1 -> 2 [label = "a, b"]
  1 -> 3 [label = "c"]
  2 -> 2 [label = "b"]
  2 -> 4 [label = "c"]
  3 -> 3 [label = "b"]
  3 -> 4 [label = "a, b"]
  4 -> 4 [label = "b"]
}

to compile with dot2tex -f tike --tikzedgelabels --graphstyle=automaton --crop -w --nominsize --autosize ex.dot > ex.tex && texi2dvi --pdf ex.tex, in which case I get the following result. The edges are too long, but overall, it looks nice.

Rendering in TikZ format

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.