blog @ bjerck.net

Login Register

Graphviz, pstricks and pdftex

by: tom

For my latest assignment in an algorithms course, I was required to produce a report in the form of a pdf document. The report would contain graphics of binary trees. To produce these I used the graphviz software. With this software graphs are produced from an input file containing instructions in a simple language called dot. This language doesn't give you exact control over the placement of nodes in the graph, rather, you use the language to indicate the existence of, and relationship between nodes. The program which interprets the input files, also called dot, produces graphics in a vast number of types, but not eps. At least not in the version of dot on my system. So in order to make scalable graphics I used pdf output. To trim white space from the pdf file before including it as graphics in my latex code I had to use the pdftrimwhite program.

There is an alternative to graphviz; the pstricks package. It is a powerful graphics package for latex, but it is not nearly as simple to use as including graphics made by graphviz. The first problem I ran into was that on my system the latex command is a symbolic link to pdftex. And pdftex can't be used with the pstricks package. The simplest way to work around this, is to use the "pst-pdf" package. Just add the line:
\usepackage{pst-pdf}
to your latex document preamble. You now may use the pstricks package, but you have to compile the .tex file in four stages:
latex <file>.tex
dvips -o <file>-pics.ps <file>.dvi
ps2pdf <file>-pics.ps
pdflatex <file>.tex
You must add -pics to the file names where indicated. If you want a simpler way you may use the script ps4pdf which does the steps above:
ps4pdf <file>.tex

Also, there is PGF & TikZ which is easier to use than pstrics and works great with pdftex. It also has a comprehensive and well made user manual.


created: 2009-03-03 18:26:06. Permalink

Firefox 2