Introducing dot2texi: Create graphs within LaTeX using dot2tex
- Published 2007-11-12 (2 years, 3 months ago)
The dot2texi package is a LaTeX package for embedding graphs in the DOT graphs description language directly in your LaTeX file. Graphs are created within the special dot2tex environment. When compiling the document the following will happen:
- The content of the dot2tex environments are written to file.
- dot2tex is run on the saved files.
- The generated code is included in the document and rendered.
The above process is completely automated if write18 or shell escape is enabled when running TeX.
The main advantage of using dot2texi is that you can keep everything within your document. No need to keep graphs in separate files. It is also easy to keep a consistent look and feel.
Here is a simple example
\documentclass{article}
\usepackage{dot2texi}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\begin{dot2tex}[neato,options=-tmath]
digraph G {
node [shape="circle"];
a_1 -> a_2 -> a_3 -> a_4 -> a_1;
}
\end{dot2tex}
\end{document}
To generate the graph you have to run LaTeX with shell escape enabled since dot2tex is called in the background:
$ pdflatex --shell-escape graphdemo.tex

The package is available on CTAN. See the documentation for more details.
Acknowledgements
The package is based on the dottex and gnuplottex packages wirtten by Lars Kotthoff. He has done most of the heavy lifting. I have just adapted the code for use with dot2tex.

Comments
-
- #1 Jay A. Patel, November 13, 2007 at 6:04 a.m.
-
-
- #2 Kjell Magne Fauske, November 13, 2007 at 8:49 a.m.
-
-
- #3 Jagadish, September 25, 2008 at 8:26 p.m.
-
-
- #4 Kjell Magne Fauske, September 26, 2008 at 8:27 a.m.
-
-
- #5 Malpel, January 19, 2009 at 11:31 a.m.
-
-
- #6 Malpel, January 19, 2009 at 11:43 a.m.
-
-
- #7 don, March 6, 2009 at 9:18 p.m.
-
-
- #8 Kjell Magne Fauske, March 6, 2009 at 10:13 p.m.
-
Comments are disabled for this entryHi,
I was intending to use your dot2tex.py script, when I ran into the doc2texi.sty package released today. Wow, talk about good timing.
Anyway, I am a complete novice when it comes to LaTeX (well, I know how to use it to a very limited extent -- but nothing about writing my own .sty files). So, I am not able to do much more then report a "bug".
I am using Ubuntu 7.04 w/ pdfeTeX 3.141592-1.21a-2.2 (Web2C 7.5.4):
I get this problem when trying to compile docgraphs.tex in the examples/ directory:
Any clue why LaTeX is choking on that particular line of the doc2texi.sty file? Is this something on my end only? If so, can you mention a quick fix?
Thanks for all your contributions to the LaTeX universe.
Cheers, Jay.
@Jay Thank you for your interest in using dot2texi. From your error message it seems that your system chokes on a command from the xkeyval package. My first guess is that you may have an old version of xkeyval installed. Choicekeys were added in version 2.3. The current version is 2.5.f. You'll find this information in the log file.
For debugging purposes I recommend trying the minimal example from the manual. The docgraphs example uses for instance the preview package. That may complicate things.
How do you pronounce your name?
@Jagadish The Kj sound is not used in English, so it is a bit difficult to write how it is pronounced. You can try typing my name in this text-to-speech tool, selecting Swedish. The result is pretty close to the Norwegian pronunciation.
I seem to have a problem using
\inputto include an external file.If I put
\input{filename.dot}, I getdocname-dot2tex-fig1.dotcontaining a single line, including the braces:{filename.dot}Here is a complete doc I compile with pdflatex -shell-escape docname.latex:
I was this and it works by adding empty brackets after begin, like so:
begin{dot2tex}[]What an amazing package! I am having only one trouble, and that is getting a graphviz to size to fit the page width. I am using dot2texi and not having luck setting size and ratio parameters on the graph. Is there a way to get dot2tex to auto-scale?
thanks!
Thanks Don. I answered a similar question on the dot2tex-users list some time ago. You can find my answer here. Not sure if this is exactly what you want.