TeX - LaTeX Asked by sampablokuper on December 18, 2020
Is it possible to use the verbatim environment (i.e. begin{verbatim}...end{verbatim}
) in a dot2tex node? If so, please could you provide a MWE?
Update: this is the closest I’ve got so far:
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;
}
And this is the output from turning it into a PDF via the command dot2tex --crop --margin 1em --autosize dot2tex_test_006_mwe.dot > dot2tex_test_006_mwe.tex; pdflatex dot2tex_test_006_mwe.tex
:
This is unsatisfactory in at least two ways:
instead of
verb|echo '*.swp' >> .gitignore|verb|echo '.DS_Store' >> .gitignore|
I would much prefer to have been able to use
begin{verbatim}
echo '*.swp' >> .gitignore
echo '.DS_Store' >> .gitignore
end{verbatim}
to avoid the need for unnecessary markup for every newline in the code block, but the latter generated the following errors:
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.
)
*
The verb|...|
approach in the MWE does not render the code verbatim. Even my short example has the following problems:
*.swp
and .DS_Store
have been replaced by right single quote marks;I can't get the round shapes, independently on what text I add.
However, the solution is to use more lines.
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;
}
Answered by egreg on December 18, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP