Dot2tex v. 2.0.0 released
- Published 2007-04-23 (1 year ago)
I'm pleased to announce a major new release of dot2tex. Highlights of the new release are:
- A new preprocessing mode that will adjust the size of nodes and edge labels to fit the output from LaTeX.
- Better error handling. Added logging for debugging purposes.
- More control of vertical label alignment.
There is now also a mailing list/group available, dot2tex-users, where you can ask questions and look for answers.
Graph preprocessing
The “killer feature” of this release is the ability to automatically adjust size of nodes and edge labels to fit the output from LaTeX. This solves a major weakness of the previous versions, where manual adjustments were required to ensure that labels would fit. This is possible thanks to the preview package by David Kastrup.
The preprocessing works like this:
- Node and edge labels are extracted and the corresponding LaTeX markup is saved to a temporary file.
- The file is typeset with LaTeX and information about sizes is extracted using the preview package.
- A new dot file is created where node and edge label sizes are set using the dot language's width and height attributes.
- The generated graph can now be processed using Graphviz and dot2tex. Label sizes will now correspond with the output from LaTeX.
Here is an example graph:
digraph G {
node [shape=circle];
a_1 [texlbl="$x^2+\frac{\sin y}{y^2+\cos \beta}+\gamma_3$"];
a_1 -> a_2 [label=" ", texlbl="$x_1+x_3^2+z+c+v~~$"];
a_2 -> a_1;
}
Rendered with
$ dot2tex -tmath example.dot > example.tex
the graph will look like this:

With previous version of dot2tex the only solution would be to pad the label attributes or set a fixed node width. With the new version you can use the preproc option like this:
$ dot2tex.py -tmath --preproc example.dot > exampletmp.dot
$ dot2tex.py exampletmp.dot > example.tex
or more compact:
$ dot2tex.py -tmath --preproc example.dot | dot2tex.py > example.tex
The resulting graph is now much better, thanks to the adjustment of node and edge sizes during the preprocessing step:

Future plans
My next plan is to implement a few simpler and more application specific versions of the output formats. PGF/TikZ for instance, has elegant libraries for drawing nodes, edges, automata and such. This can be utilized to create graphs with more compact and elegant code. The visual results will in some cases also be better. This is especially true for edges and how they are cut at the node boundaries.
I appreciate all feedback on how to improve dot2tex!

Comments
Post a comment
Markdown syntax enabled