style含义太多(编辑)

style含义太多(编辑)

我正在尝试使用 dot2tex 渲染自动机。由于我不明白的原因,渲染缺少一些框。

对于以下 Dot 文件输入:

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"]
}

使用dot2tex --crop --nominsize --autosize --usepdflatex ex.dot > ex.tex && texi2dvi --pdf ex.tex编译,我在生成的 PDF 中根本没有显示一个框:

在此处输入图片描述

根据要求,这是生成的 LaTeX 文件:

\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}
%

如果我注释节点 I0 和 F4 的定义,那么我会得到一些框,但不是全部!我更喜欢圆形框,但这似乎也不能正常工作。

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"]
}

我读过文档,没有发现什么有趣的东西。tikz 输出也有同样的问题。我查看了 xdot 输出,它确实输出了框,问题似乎来自 dot2tex。我读过 --debug 日志,没有发现任何可疑之处。

我是否遗漏了什么?

提前致谢!

style含义太多(编辑)

好吧,看来我按照 Graphviz 的期望使用了“样式”;但是 dot2tex 也会将其解释为 TikZ 样式以应用于节点。这可能是我得到奇怪结果的原因。

进一步的经验使我得到了以下 Dot 输入文件:

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"]
}

进行编译dot2tex -f tike --tikzedgelabels --graphstyle=automaton --crop -w --nominsize --autosize ex.dot > ex.tex && texi2dvi --pdf ex.tex,在这种情况下我得到以下结果。边缘太长了,但总体来说,看起来不错。

以 TikZ 格式渲染

相关内容