是否可以在 dot2tex 节点中使用“verbatim”环境?

是否可以在 dot2tex 节点中使用“verbatim”环境?

是否可以使用 verbatim 环境(\begin{verbatim}...\end{verbatim}dot2tex节点?如果是,您能否提供 MWE?


更新:这是目前为止我得到的最接近的更新:

digraph g {
d2tdocpreamble = "\usepackage{varwidth} \usepackage{verbatim} \renewcommand{\familydefault}{\sfdefault}";
graph [ rankdir = "TB" ];
node  [ style="rounded,bold,filled" fillcolor="azure" shape = "box" ];

assume_git         [ texlbl="\begin{varwidth}{30em}We'll assume that Git is to be used for source control; so as a precaution against accidentally checking in temporary files used by Vim or OS X, enter the following at the command prompt:\\\verb|echo '*.swp'      >> .gitignore|\\\verb|echo '.DS\_Store'  >> .gitignore|\end{varwidth}" ];

START              -> assume_git;
}

这是通过命令将其转换为 PDF 的输出dot2tex --crop --margin 1em --autosize dot2tex_test_006_mwe.dot > dot2tex_test_006_mwe.tex; pdflatex dot2tex_test_006_mwe.tex

在此处输入图片描述

这至少在两个方面令人不满意:

  1. 代替

    \\\verb|echo '*.swp'      >> .gitignore|\\\verb|echo '.DS\_Store'  >> .gitignore|
    

    我更希望能够使用

    \begin{verbatim}
    echo '*.swp'      >> .gitignore
    echo '.DS_Store'  >> .gitignore
    \end{verbatim}
    

    以避免代码块中每个换行符都需要不必要的标记,但后者产生了以下错误:

    ERROR    Failed to process input
    Traceback (most recent call last):
      File "build/bdist.macosx-10.6-universal/egg/dot2tex/dot2tex.py", line 2928, in main
        s =  conv.convert(dotdata)
      File "build/bdist.macosx-10.6-universal/egg/dot2tex/dot2tex.py", line 794, in convert
        return self.do_preview_preproc()
      File "build/bdist.macosx-10.6-universal/egg/dot2tex/dot2tex.py", line 1105, in do_preview_preproc
        hp,dp,wt = pp.texdims[name]
    KeyError: 'assume_git'
    This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011/MacPorts 2011_5) restricted \write18 enabled.
    entering extended mode
    (./dot2tex_test_006_mwe.tex
    LaTeX2e <2009/09/24>
    Babel <v3.8l> and hyphenation patterns for english, dumylang, nohyphenation, czech, slovak, dutch, ukenglish, usenglishmax, basque, french, german-x-2009-06-19, ngerman-x-2009-06-19, german, ngerman, swissgerman, italian, polish, portuguese, spanish, catalan, galician, loaded.
    )
    *
    
  2. MWE 中的方法\\\verb|...|不会逐字呈现代码。即使我的简短示例也存在以下问题:

    • 为了避免出现错误消息,我不得不在下划线前面添加一个反斜杠,但现在反斜杠被渲染了。所以我需要一种方法来渲染只是下划线;
    • *.swp和周围的直单引号.DS\_Store已被右单引号取代;
    • 每对大于号中的一个成员已经消失。

答案1

无论我添加什么文本,我都无法获得圆形。

然而,解决方案是使用更多线路。

digraph g {
d2tdocpreamble = "
  \usepackage{varwidth}
  \usepackage{verbatim}
  \usepackage{upquote}
  \renewcommand{\familydefault}{\sfdefault}
";
graph [ rankdir = "TB" ];
node  [ style=rounded, fillcolor=azure];

assume_git [ texlbl="\begin{varwidth}{30em}
  We'll assume that Git is to be used for source control; so as a precaution against
  accidentally checking in temporary files used by Vim or OS X, enter the following
  at the command prompt:
  \begin{verbatim}
  echo '*.swp'      >> .gitignore
  echo '.DS\_Store'  >> .gitignore
  \end{verbatim}
  \end{varwidth}"
 ];

START              -> assume_git;
}

在此处输入图片描述

相关内容