TikZ (and LaTeX) driver for Graphviz?

If you are referring to post 18, it was a lack of bug problem. I was trying to reproduce the bug that inhibits hyperlinks when a PostScript middlestep is taken. I could not reproduce the bug. If I could have reproduced the problem Jack was having, it might have revealed how the hyperlinks are encoded in PostScript to render in PDF. In the end it just means GV bug 1991 will need some investigative work to know how it’s done.

Hi,

I wonder if there is any progress on this topic? I found myself too many times in the situation to want a quick way to draw a graph but with LaTeX formula labels.

One problem I’m seeing to generate LaTeX directly from graphviz is that I think it would be hard for the layout engine to detect correct label sizes (since one need to invoke a TeX compiler at least once to size the formulas correctly).

One idea is to integrate some kind of “recompilation strategy” in a standalone LaTeX package. Specifically, the package takes two compilation runs (quite common in TeX land):

  • In the first TeX compilation run, the package invokes graphviz to extract all the TeX in the input .dot file. The package then compiles all the formulas with TeX and store the sizes in a temporary file.
  • In the second TeX compilation run, the package then pass that information to graphviz to create a TeX file with the node location that respects the correct label sizes.

It seems to me what’s missing right now are:

  • A way to let graphviz commandline to parse the input .dot and output all the TeX
  • A way to let graphviz emit LaTeX or tikz output.

Implementing the first point would already handle most of my use case, when I don’t need LaTeX outputs. In particular, I can write a simple script to convert all the TeX formulas into SVGs, then pass them back to use a standard graphviz backend.

Graphviz has no understanding of what is TeX and what is other label text (IIUC you’re now trying to extract raw TeX that’s been written in Graphviz labels). But maybe you just want the -Tjson option to dot combined with a post-processing script to extract the label text?

  • there are no open requests to add a Tikz/latex driver. I am not working on it (and do not expect to) Feel free to add a request (Issues · graphviz / graphviz · GitLab), but it might not be addressed for a long time, unless you do the work
  • Adding a Tikz driver for everything EXCEPT TEXT would be “pretty easy” as long as you stayed within the current bounds of Graphviz. The driver documentation is quite complete & pretty easy to use. As noted, the text part (the important stuff) would require more investigation and an unknown amount of work.
  • if you just want tex/latex output inserted into Graphviz nodes (not non-node labels), maybe you can do it now (maybe).
    • produce each of your labels and get dimensions (in points or inches) from lex/latex/tikz
    • explicitly set Graphviz node sizes accordingly. set label text to “”
    • use dot2tex (or similar) (see references above) to convert all the non-text stuff to tex/latex/tikz
    • embed your text (via an include statement?) into the output of the Graphviz-to-text converter
    • easy (OK, not easy, but maybe doable, and maybe scriptable)