-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphviz.sty
44 lines (38 loc) · 1.39 KB
/
graphviz.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
% graphviz.sty
% by Mark Aufflick
% 2006-03-25
% mark@aufflick.com
% http://mark.aufflick.com/
%
% 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 #2.dot
\ProvidesPackage{graphviz}
\newcommand{\digraph}[3][scale=1]{
\newwrite\dotfile
\immediate\openout\dotfile=#2.auto.dot
\immediate\write\dotfile{digraph #2 {\string#3}}
\immediate\closeout\dotfile
\immediate\write18{bash -c "dot -Tps2 #2.auto.dot | epstopdf --filter -o=#2.pdf"}
\IfFileExists{#2.pdf}
% the pdf exists: include it
{ \includegraphics[#1]{#2} }
% the pdf was not created - show a hint
{ \fbox{ \begin{tabular}{l}
The file \texttt{#2.pdf} hasn't been created from
\texttt{#2.auto.dot} yet. \\
We attempted to create it with:\\
`\texttt{dot -Tps2 #2.auto.dot | epstopdf --filter -o=#2.pdf}' \\
but that seems not to have worked. You need to execute `\texttt{pdflatex}' with \\
the `\texttt{-shell-escape} option. You also need `\texttt{epstopdf}' from CTAN.
\end{tabular}}
}
}