dot2tex 不会绘制像“doublecircle”这样的形状

dot2tex 不会绘制像“doublecircle”这样的形状

我当时正在关注教程尝试将点图添加到 latex。我不太了解点代码,我只是复制粘贴了它,但我认为它在最终的 pdf 中没有按预期显示。

点代码

digraph simpleFA
{
    rankdir=LR;
    node [shape="point"] start;
    node [shape="circle"] p0;
    node [shape="circle"] p1;
    node [shape="doublecircle"] p2;
 
    start -> p0;
 
    p0 -> p0 [label="0"];
    p0 -> p1 [label="1"];
 
    p1 -> p2 [label="0"];
    p1 -> p1 [label="1"];
 
    p2 -> p2 [label="0,1"];
}

我在 Windows 上使用 cygwin 和 MikTex。在 cygwin 中运行pip install dot2tex。然后我执行dot2tex -o temp.tex --prog dot temp.dot(除此以外的任何选项dot都只会产生更糟糕的结果)。

生成的 LaTex 代码

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

%

%

\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}
%%
\pgfsetcolor{black}
  % Edge: p2 -> p2
  \draw [->] (223.22bp,47.126bp) .. controls (222.45bp,57.406bp) and (225.15bp,66.296bp)  .. (231.34bp,66.296bp) .. controls (235.3bp,66.296bp) and (237.84bp,62.648bp)  .. (239.46bp,47.126bp);
  \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
  \pgfsetstrokecolor{strokecol}
  \draw (231.34bp,73.796bp) node {0,1};
  % Edge: p1 -> p1
  \draw [->] (136.85bp,42.991bp) .. controls (135.63bp,53.093bp) and (138.03bp,62.296bp)  .. (144.04bp,62.296bp) .. controls (147.9bp,62.296bp) and (150.27bp,58.519bp)  .. (151.24bp,42.991bp);
  \draw (144.04bp,69.796bp) node {1};
  % Edge: p1 -> p2
  \draw [->] (164.29bp,24.148bp) .. controls (173.99bp,24.148bp) and (185.87bp,24.148bp)  .. (207.17bp,24.148bp);
  \draw (185.69bp,31.648bp) node {0};
  % Edge: start -> p0
  \draw [->] (3.7613bp,24.148bp) .. controls (8.1357bp,24.148bp) and (19.192bp,24.148bp)  .. (40.58bp,24.148bp);
  % Edge: p0 -> p1
  \draw [->] (80.912bp,24.148bp) .. controls (90.763bp,24.148bp) and (102.82bp,24.148bp)  .. (123.78bp,24.148bp);
  \draw (102.4bp,31.648bp) node {1};
  % Edge: p0 -> p0
  \draw [->] (53.874bp,43.384bp) .. controls (52.816bp,53.331bp) and (55.108bp,62.296bp)  .. (60.748bp,62.296bp) .. controls (64.274bp,62.296bp) and (66.491bp,58.794bp)  .. (67.623bp,43.384bp);
  \draw (60.748bp,69.796bp) node {0};
  % Node: p2
\begin{scope}
  \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
  \pgfsetstrokecolor{strokecol}
  \draw (231.34bp,24.148bp) node {p2};
\end{scope}
  % Node: start
\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: p0
\begin{scope}
  \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
  \pgfsetstrokecolor{strokecol}
  \draw (60.748bp,24.148bp) node {p0};
\end{scope}
  % Node: p1
\begin{scope}
  \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
  \pgfsetstrokecolor{strokecol}
  \draw (144.04bp,24.148bp) node {p1};
\end{scope}
%
\end{tikzpicture}
% End of code

%
\end{document}
%

在我看来,节点的形状没有进入 LaTex 代码,因为我找不到任何看起来像圆圈的代码。
使用 TexWorks(pdftex+MakeIndex+BibTex,默认选项)编译此代码会得到以下图表:
图形

我本来期望节点周围有一些圆圈和双圆圈。我怎样才能解决这个问题?

我努力了:

  • MikTex 的全新安装
  • 另一台计算机,但也装有 Cygwin、Windows 10、MikTex
  • 使用--figonly标志
  • 使用不同的--prog选项

我相信我已经安装了所有相关软件包。我必须安装的是:

  • 彩色
  • 前列腺素
  • pgf工具

可能的解决方案/解决方法
在 Adob​​e Acrobat Distiller 中运行dot -Tps temp.dot -o temp.ps并打开 ps 文件会按预期生成图形。图表符合预期

或者更好的是:dot -Tpng temp.dot -o temp.png直接获取图形。

但这似乎不是一个真正的解决方案——我不太明白到底发生了什么,但我认为dot2tex它应该有效。

我正在寻找解决方案,而不是寻找不同的解决方法,但我确信其他方式对于未来的游客来说也会有用。

答案1

操作非常简单pstricks

\documentclass[svgnames, border =30pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{pst-node}
%\usepackage{auto-pst-pdf} % to compile with pdflatex --enable-write 18 (MiKTeX)) or pdflatex --shell-escape (TeX Live, Mac TeX)

\begin{document}

\small
\psset{arrowinset=0, linejoin=1,shortput=nab,linejoin = 1}
\def\pscolhookii{\hspace{-0.2cm}}%
\def\pscolhookiv{\psset{doubleline, doublesep = 2pt}}
$ \begin{psmatrix}[mnode =circle, colsep = 0.8cm, emnode = dot]
 & [name = p0] p_0 & [name = p1] p_1 & [name = p2] p_2
\psset{arrows = ->, doubleline = false}
\foreach \s/\t in {{1,1}/p0, p0/p1, p1/p2}{\ncline{\s}{\t}}
\psset{angleA = 65, angleB = 115, ncurv = 5, arrows = <-}
\foreach \p/\label in {p0/0,p1/1,p2/0.1}{\nccurve{\p}{\p}\nbput{\label}}
    \end{psmatrix} $

\end{document} 

在此处输入图片描述

答案2

看起来这是一个已知的错误: https://github.com/kjellmf/dot2tex/issues/44
-罗斯

在该链接中:

expbbc 于 2016 年 12 月 29 日发表评论

此问题已于 2014 年修复:914f805
Kjellmf 从未费心将更新版本推送到 pip。

最新版本可用在 Github 上是最新的(当前版本2.10.dev),而 的版本pip仍为2.9.02014 年的版本。

因此,对于遇到同样问题的人来说......

修复

首先,卸载从 pip 获取的旧版本。

pip uninstall dot2tex

然后,导航到要下载新版本的某个目录并获取文件。这将创建一个新目录dot2tex

git clone https://github.com/kjellmf/dot2tex.git

现在再次安装它。

cd dot2tex
python setup.py install

就我而言,它自动将 dot2tex 添加到路径环境变量中,因此现在可以工作了。

dot2tex --prog dot -o temp.tex temp.dot

现在输出包含类似这样的行\draw (60.75bp,24.15bp) ellipse (20.3bp and 20.3bp);。编译后的 Latex pdf 与的输出相匹配dot

答案3

withtikz也很简单:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{automata, chains, quotes}

\begin{document}
    \begin{tikzpicture}[
      node distance = 12mm,
        start chain = going right,
state/.append style = {on chain, join=by -latex},
               auto = left
                    ]
\coordinate[on chain] (in);
\node (p0) [state] {$p_0$};
\node (p1) [state] {$p_1$};
\node (p2) [state,double] {$p_2$};
\fill (in) circle (1pt);
\draw[->]   (p0) edge [loop above,"0" ] ()
            (p1) edge [loop above,"2"]  ()
            (p2) edge [loop above,"0.1"] ();
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容