Begin main content

Embedding GraphViz in LaTeX documents

I have to say I'm loving using LaTeX for my Uni papers. It is so delightfully straightforward and powerful.

I am embedding some GraphViz diagrams in my documents, but I didn't want a round trip to a different editor buffer and the shell to edit/compile/insert the diagram.

Based on graphviz.tex code by Derek Rayside I have created a custom LaTeX function that will automatically compile and embed inline GraphViz code (man those wacky capitilisations are getting boring!)

You embed a graph like so:

   \digraph[scale=0.5]{MyGraph}{rankdir=LR; a->b; b->c}
Be careful not to have any double newlines or your dot file will have some bogus \par comments in it (which I should replace with newlines in the function...). Another possible enhancement would be to add a dynamic dot command to set the maximum diagram height & width to the current page/column dimensions.

You need my graphviz.sty and you need the following in your document preamble:

Remember to run texhash if you install the style in a system-wide location. Note this assumes pdflatex. Modifying the command for regular latex is an exercise left for the reader. Update: Derek now has an updated version available on GitHub (which didn't exist in 2007 :).

08:09 AM, 25 Mar 2007 by Mark Aufflick Permalink


Change this style to use the excellent dot2tex:

by Mark Aufflick on 05/21/07


Awesome! This was very useful for me.

by Unregistered Visitor on 02/13/09

Thank you

I really like this, and I fiddled around with dot2tex as suggested in your comment to yourself. Here are my results. I've never written a latex sty file before, so please feel free to improve it.

% graphviz.sty
% by Mark Aufflick
% 2006-03-25
% based on graphviz.tex by Derek Rayside 2003

% add the following lines to your preamble:

% \usepackage[pdftex]{graphicx}
% \usepackage{graphviz}

% parameters to \digraph:
% 1 - parameters for \includegraphics (optional; default value is "scale=1")
% 2 - name of the digraph
% 3 - body of the digraph

% assumes pdflatex. to modify this command for regular latex,
% replace all .pdf with .ps, and the command becomes simply:
% dot -Tps


  \immediate\write\dotfile{digraph #1 {\string#2}} 
  \write18{bash -c "`which neato` -Txdot | `which dot2tex` -tmath --figonly --usepdflatex -ftikz --tikzedgelabels --styleonly -o #1tikz.tex"}  
  % the tex exists: include it 
  { \include{#1tikz} } 
  % the tex was not created - show a hint
  { \fbox{ \begin{tabular}{l} 
        The file \texttt{#1tikz.tex} hasn't been created from 
        \texttt{} yet. \\
        We attempted to create it with:\\
        `\texttt{neato -Txdot | dot2tex  --figonly --usepdflatex -ftikz --tikzedgelabels --styleonly -o #1tikz.tex}` \\
        but that seems not to have worked. You need to execute `\texttt{pdflatex}` with \\
        the `\texttt{-shell-escape}` option.

by Unregistered Visitor on 04/02/09

Something to be wary of

You should not have the \newwrite directive in your \newcommand. If you do and use it a lot you will exhaust the write buffers available. Just move that command out of the \newcommand block. Like: \newwrite\dotfile \newcommand{\digraph}[4][scale=1]{ \immediate\openout\ etc.

by Unregistered Visitor on 10/06/10

Updated version on Github

For an updated version of GraphViz.sty see Mike Prentice's Github version:

by Mark Aufflick on 02/23/11

Filenames with hyphens

If you want filenames with hyphens in them, put quotes around #2 in the following line: \immediate\write\dotfile{digraph #2 {\string#3}}

by Unregistered Visitor on 04/02/13

Accents and labels with spaces

Very nice functionality! But how do you prevent PDFLaTeX from introducing strange codes when using spaces and accented characters in, e.g. label? Example: try the following \digraph[scale=0.5]{MyGraph}{rankdir=LR; a [label="This is A"]; a->b; b->c} If I drop the double quotes there will be three nodes instead of one, and any replacement of the quotes by single quotes or braces, will result in strange nodes labeled with LaTeX items from when it processes the box; just like when the label string contains accented characters. Solving this would, for my use, make graphviz.sty full featured. Best regards, Morten Lind.

by Unregistered Visitor on 06/27/13

Updated version on Github

I just uploaded a newer version of this to Github: cheers, Derek.

by Unregistered Visitor on 08/15/13


The relationship developed by all understudies as they mutually do their school studies keeps them spurred and - essay writing service the members have a tendency to have more chances to impart as they create improve their abilities.

by Unregistered Visitor on 10/22/14


See several online business blogs regularly from the se like msn, yahoo or simply bing, read up to date post, and prepare a comment about that. Make certainly your provide feedback is bond with their blog as well as an ad in your business. How you'll get more customers? Leave your blog or website during the comment You simply will not believe any traffic you can generate using the simple theory. Commenting regarding other online business blogs is quick and easy. wetakecareofbusiness

by Unregistered Visitor on 10/23/14


Lake say That i tried most of the not suitable tips on how to make money via the internet, I lead to it. I did the webpage with Adsense, used Click Loan provider with online info training books, Amazon's affiliate marketing, and other. I assume if others were definitely prospering for doing experiencing results it was going to be easy for me that will copy. I at all times knew That i needed any adaptability and way of living that the webs business be ready to provide however , I was initially still working for others. treefinance

by Unregistered Visitor on 10/23/14


The main advantages of franchising into the franchisor happen to be that franchisee will have to buy license within the franchisor to exercise the business. To shop for this driver's license, the franchisee pays huge amount into the franchisor, together with besides the, pays a good monthly bill for holding that identity. Moreover, a franchised online business can grow quicker than if ever the owner might possibly be responsible that will finance most of the outlets. At the same time, the process might possibly be cumbersome. iutcfinance

by Unregistered Visitor on 10/23/14


Own your history ready when trying to find a life insurance policy, because patiently waiting may be a hassle for just anyone. You recognize that they will request your history, and except when you've kept track of it all by yourself, the hospital's reports system might take weeks or simply months to build it to your. riversourceinsurance

by Unregistered Visitor on 10/23/14


What is more, in component to valuables insuranc policy, there are definitely covers available so that you can seriously think of when two hundred thousand dollar motor 18 wheeler cargo insurance. Refrigerator braking system down, generated freight coverage, loading together with unloading policy, and larceny coverage would definitely be a few a single article. However, it is your job whether so as to add these even more optional coverage towards your truck cargo insurance for one small portion for additional superior. Anyway, you might want to make the selection carefully in an effort to maximize an individual's scope for cover. insurancelikeitshoulbe

by Unregistered Visitor on 10/23/14


Grown-up learners are given a chance of composing their engaged Essay Thinker to write my essay assignments the way they feel more adaptable so long as they convey well. In any case they must be watchful that all is carried out inside the obliged principles while they include their teachers to provide for them more direction. Don't make presumptions that all you will do will be checked as right.

by Unregistered Visitor on 10/24/14

houses to rent brisbane

I'm impressed. houses to rent in australia I try to keep a couple blogs somewhat current, but it's a struggle sometimes. Well done. brisbane houses for sale There's a bunch of good information here. property for sale perth I'm impressed. brisbane houses for sale

by Unregistered Visitor on 10/30/14

thank a lot

Created with the specialised documents industry in purpose the 44\" schoolwide iPF825 outputs documents atlantic thing only a family of samples of the calibre of writing the imagePROGRAF module manipulate. if you need the driver printer, you can check at download Driver Canon imageprograf ipf825 Aesthetically, real slight is completely diverse from incompatible Epson dedicated danger printers; it\'s monovular bucket-and-handle communication of the PictureMate if you need the driver printer, you can check at download driver epson picturemate pm235 Naturally, it cannot stop a candela to the One\'s indulgent name and 4.7in, 1080p guide, object for a sub-£200 sound the give 500 is uncommonly glorious. Its shiny discolor plastic phrase is around off nicely by a color dirty take that surrounds the force and seamlessly encompasses the honor buttons on the right-hand urgency. if you need the gadgets info, you can check at specifications review htc desire 500 Using deain groundwork of 1 of the most favourite Mitsubishi SUV beginning referred to as GG - PHEV , the most recent procreation Pajero was present to circularise the populate runway high-powered hit - in organism if you need the last info about car automotive, you can check at review pajero Mitsubishi gg phev bilang untuk memasang iklan Adsense di diary, kita harus mendaftar adsensenya dari Blogger, tidak bisa dari youtube lagi if you need the last info update about technology, you can check at kita echo pengenalan google adsense PIXMA MG7570 picture the PIXMA bit & Photo fulfil with NFC susceptibility, which suggests users don't got to control urbane meshwork settings. Users can turn documents or... if you need more info about geophysics, you can check at Download Printer Rahmat Punya Driver

by Unregistered Visitor on 10/30/14


that will provide for them the urge to need to find and learn new things. You will be amazed at how write my paper for me quick they find themselves able to handle things even with their guiltless age.

by Unregistered Visitor on 10/30/14

essay writing

Thanks for writing this post, Its really extensive and help full for my write my essay writing service for me. I will pay good amount.

by lewis paul on 10/31/14


well done guys i hope to see too much from you also jogos de motos

by Unregistered Visitor on 10/31/14


this is actually a very well iece of the information guys 200 calorie meal plans

by Unregistered Visitor on 11/02/14

New york meditation classes by light watkins

Do you want to New york meditation classes by light watkins Light Watkins has been providing meditation course from many year in new york.Get the best meditation audio course online and best personal trainer now.

by Unregistered Visitor on 11/03/14

hay day hack

Bovendien is in veel van de stembureaus Hay day hack in Alba Iulia meeste kiezers die hun recht om te stemmen in de ochtend uitgeoefend waren ouderen. Op het stembureau in het district van de stad Lipoveni tot 13:00 bijna 15 procent van de kiezers had gestemd, vooral ouderen, zeggen vertegenwoordigers van de afdeling.

by Unregistered Visitor on 11/03/14

minecraft poket edition hack

. Washington-fondé Microsoft moment de la clôture en Décembre. "Minecraft" a vendu près de 54 millions d'exemplaires à travers un certain nombre de plates-formes minecraft poket edition hack comme de Juin. "Minecraft: Pocket Edition" arrive aussi sur les téléphones Windows dans le futur, mais aucune date de sortie ...

by Unregistered Visitor on 11/03/14

dsgseges These scenes are entertaining render videos, but they do not show the actual game graphics. Such as "Clash of Clans" in reality looks and plays, for example, shows the subscriber of more than one million people YouTube channel

by Unregistered Visitor on 11/04/14


clash of clans hack X-Bow’s reach their full level at level 4. The X-Bow is turret that’s capable of shooting down ground units at long range or all units at a reduced range. You’ll have to load them up with Elixir in order to get them to start defending you. You should place your X-bow’s near your storage buildings and your Town Hall. clash of clans cheats

by Unregistered Visitor on 11/04/14

amazing post

Votre voyance amour est gratuite, alors n'attendez plus, c'est le moment de vivre !

by Unregistered Visitor on 11/05/14


Easily, the paper is indeed the prize matter on this registry pertinent flow. I competent in accompanying your opinions further endow eagerly leer encourage to your following modernizes. Right axiom bless endow negative barely be adequate, for the fantastic c lucidity in your essay. I pleasure instantaneously take your rss furnish to delay conversant of some renews.

by Unregistered Visitor on 11/09/14

enjoy it

I want to to numerous enjoy it only for that will astounding investigation! coach factory outlet

by Unregistered Visitor on 11/10/14

Obagi Products

Great post! I am actually getting ready to across this information, is very helpful my friend. Also great blog here with all of the valuable information you have. Keep up the good work you are doing here. Obagi Products

by ahmed raza on 11/10/14


I was actually going through the nice helpful tips from the blog and I put respect to the writer of this post,Hurricane Shutters Hobe Sound enjoying the smart way you write articles in this

by Unregistered Visitor on 11/10/14

home cleaning

It was great to see the old printshop and everyone who works there again. I am excited to see a printing business still operating and growing, great job guys home cleaning

by ahmed raza on 11/11/14


it is creating a considerable measure of destruction among the youngsters on account of the distractive Really professional essay writing service materials that they find themselves able to get t

by Unregistered Visitor on 11/11/14


Barely a month after the last update of the farm game for smartphones and tablets brings the mobile games studio Supercell (Clash of Clans, Boom Beach) the next features for Hay Day for language. For a few weeks you care in the farm simulation to Busy Bee and, with the help of the honey extraction machine sweet treats as you.

by Unregistered Visitor on 11/12/14

"Best HTML5 Software"

Thanks very much for One of the best HTML5 animation software that are available in the market today. For more detailed... "Best HTML5 Software"

by ahmed raza on 11/12/14

moving companies

Thanks for creating the page! Im positive that it will be very popular. It has good and valuable content which is very rare these days. moving companies

by ahmed raza on 11/12/14

free psn codes

She was disappointed and even disgusted by the inappropriate behavior on the part of some older male colleagues that, in elevators, in full House of Commons or in county activities. free psn codes

by Unregistered Visitor on 11/12/14

Travel Information

Actually your experimental writing capacities has motivated me to begin my own particular Blogengine blog now. Truly the blogging is spreading its wings quickly. Your compose up is a fine illustration of it. Travel Information

by ahmed raza on 11/12/14

funny happy new year 2015

You have made an extraordinary showing. I will most likely burrow it and generally suggest to my companions. I am sure they will be profited from this site. funny happy new year 2015

by ahmed raza on 11/12/14

see the migration

The car seat arrived today and we have noticed that none of our pet peeves were carried over to this model! We easily got the car seat installed, ordered another Diplomat Onyx for the second car, then took junior for a spin to return the Boulevard model. I feel like we're saving a lot of money on electricity by using this instead of the toasters and full-sized oven. see the migration

by Unregistered Visitor on 11/12/14

Medical Billing Services

This is a very good article.For medical billing services visit Medical Billing Services medical billing services.

by Unregistered Visitor on 11/13/14

ps4 emulator

There was much talk of cooperation, integration and the economic interests of all parties. But Obama also reiterated that it related to military force: "The United States will modernize its defense system in the region ps4 emulator

by Unregistered Visitor on 11/15/14


Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. buy amino acids

by Unregistered Visitor on 11/15/14


While most paper composition administrations could be overpriced, managing experts will guarantee see it here that you get what is worth your cash.

by Unregistered Visitor on 11/16/14


Trying to say much appreciated won't simply be sufficient, for the fantasti c clarity in your written work. I will right away get your rss channel to stay educated of any redesigns.

by ahmed raza on 11/17/14

amazing post

Tra le strategie di opzioni binarie è sicuramente da menzionare il diario delle operazioni. strategie opzione binarie

by Unregistered Visitor on 11/19/14

Thank you for your post,

Thank you for your post, I look for such article along time, today I find it finally. This post gives me lots of advice it is very useful for me. Nice I like it. education management systems

by Unregistered Visitor on 11/21/14

Nice Post

Education tells us the culture of the area. What is the culture in our society, which we should have to maintain our culture and civilization? We should aware about our history which we have reorganization of our culture and civilization with the help of education. Professional Degree I Life Experience Degree

by Unregistered Visitor on 11/21/14

Very Nice and Informative

Hi webmaster, commenters and everybody else !!! The blog was absolutely fantastic! Lots of great information and inspiration, both of which we all need! B Keep 'em coming ... you all do such a great job at such Concepts .. . can not tell you how much I, for one appreciate all you do! Life Experience Degree I Online Bachelor Degree

by Unregistered Visitor on 11/21/14

Nice Information

That will provide for them the urge to need to find and learn new things.Also great blog here with all of the valuable information you have. Keep up the good work. banking and finance assignment

by Unregistered Visitor on 11/22/14

good post today

The line and worthy plans closely convert big new ideas to resolve right ideas in the right root of flick and it gives right ideas to follow correctly. You need to register them in right way. vote requests

by Unregistered Visitor on 11/24/14


After choosing the topic for your paper writing, it is necessary that as you begin online essay writer you can rely on, you begin with the introduction. Indicate that you will be exploring both the advantages and the disadvantages as you try to persuade the reader with your opinion. However you do not need to do a theses paper on this

by Unregistered Visitor on 11/24/14

amazing post

We love to put people together, to talk about travel experiences worldwide and to promote new friendships.youth hostel Crazy Duck Bucharest

by Unregistered Visitor on 11/25/14


I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often. Colusa Lawyer

by Unregistered Visitor on 11/25/14


Thanks for the blog post buddy! Keep them coming... Bellewwaters - Anchorvale Crescent EC by Qingjian Realty

by Unregistered Visitor on 11/25/14

amazing post

Here, it’s no doubt that you have a creative and a clearly structured review. You have done an stunning process on this particular message. Many people will obviously agree that your post was really interesting and that I can’t wait around to acquire more information. BJMC

by Unregistered Visitor on 11/25/14


Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!shipping a car

by Unregistered Visitor on 11/26/14


I am a new user of this site so here i saw multiple articles and posts posted by this site,I curious more interest in some of them hope you will give more information on this topics in your next articles. Glad to chat your blog, I seem to be forward to more reliable articles and I think we all wish to thank so many good articles, blog to share with us. used lexus cars

by Unregistered Visitor on 11/26/14


Truly, this article is really one of the very best in the history of articles. I am a antique ’Article’ collector and I sometimes read some new articles if I find them interesting. And I found this one pretty fascinating and it should go into my collection. Very good work!porsche west houston

by Unregistered Visitor on 11/26/14


This is an excellent post I seen thanks to share it. It is really what I wanted to see hope in future you will continue for sharing such a excellent used cars houston

by Unregistered Visitor on 11/26/14


It's really nice and meanful. it's really cool blog. Linking is very useful have really helped lots of people who visit blog and provide them usefull information.sherwani price

by Unregistered Visitor on 11/26/14


It is really no surprise that this building was found to have bed bugs infesting it. I mean, it is in New York city, which is pretty disgusting itself. And some of the people who work there, even if they do make decent wages, probably don't make enough to afford what is considered a "nice" place to live in New York City. Especially in midtown, of all jewelry online

by Unregistered Visitor on 11/26/14


Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.pets for sale online

by Unregistered Visitor on 11/26/14

Add comment