blob: 7bc7d28fee9eabdda7f7a7b641740025c3ddb3dc (
plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
%%
%% This is file `graphviz.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% graphviz.dtx (with options: `package')
%%
%% This is a generated file.
%%
%% Copyright (C) 2003-13 by Derek Rayside <drayside@uwaterloo.ca>
%%
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.3c of this license
%% or (at your option) any later version. The latest version of this
%% license is in:
%%
%% http://www.latex-project.org/lppl.txt
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{graphviz}
[2013/08/15 v0.94 .dtx graphviz file]
\newif\ifsinglefile
\DeclareOption{singlefile}{
\singlefiletrue
\AtBeginDocument{% open a new file handle
\newwrite\masterdotfile%
\immediate\openout\masterdotfile=\@tmpdir tmpmaster.graphviz%
\newwrite\mastergvprfile%
\immediate\openout\mastergvprfile=\@tmpdir tmpmaster.gvpr}
\AtEndDocument{% close the file
% close the dot file and the gvpr file
\immediate\closeout\masterdotfile%
\immediate\closeout\mastergvprfile%
% execute the gvpr file
\immediate\write18{gvpr -f \@tmpdir tmpmaster.gvpr \@tmpdir tmpmaster.graphviz}%
}}
\newif\ifpsfrag
\DeclareOption{psfrag}{ \psfragtrue }
\newcommand{\@outext}{ps}
\newcommand{\@outextspace}{ps }
\DeclareOption{ps}{
\renewcommand{\@outext}{ps}
\renewcommand{\@outextspace}{ps }}
\DeclareOption{pdf}{%
\renewcommand{\@outext}{pdf}%
\renewcommand{\@outextspace}{pdf }}
\newcommand{\@tmpdir}{}
\DeclareOption{tmpdir}{%
\immediate\write18{mkdir ./tmp/}%
\renewcommand{\@tmpdir}{./tmp/}}
\ExecuteOptions{ps}
\ProcessOptions\relax % LaTeX class guide says it is wise to relax
\RequirePackage{graphicx}
\ifpsfrag \RequirePackage{psfrag} \fi
\newcommand{\digraph}[2][scale=1]{
\inputdigraph[#1]{#2}{dot}% % Include the generated ps/pdf.
\@digraph{digraph}{#2}% % Generate the .dot file.
}
\newcommand{\neatograph}[2][scale=1]{
\inputdigraph[#1]{#2}{neato}% % Include the generated ps/pdf.
\@digraph{graph}{#2}% % Generate the .dot file.
}
\begingroup
\catcode`\^^M=\active%
\gdef\@digraph{\begingroup\catcode`\^^M=\active\def^^M{^^J}\@@digraph}%
\endgroup
\def\@@digraph#1#2#3{%
\ifsinglefile% write the graph to the master file
\expandafter\def\csname -\endcsname{\string\n}%
\immediate\write\masterdotfile{#1 #2 {#3}}%
\immediate\write\mastergvprfile{BEG_G { if ($.name == "#2") {writeG($G,"\@tmpdir#2.dot");} }}%
\else% open a new file handle
\newwrite\dotfile%
\immediate\openout\dotfile=\@tmpdir#2.dot%
\expandafter\def\csname -\endcsname{\string\n}%
\immediate\write\dotfile{#1 #2 {#3}}%
\immediate\closeout\dotfile%
\fi%
\endgroup}%
\newcommand{\inputdigraph}[3][scale=1]{
% execute dot or neato (nb: requires latex -shell-escape)
\immediate\write18{#3 -T\@outextspace -o \@tmpdir#2.\@outextspace \@tmpdir#2.dot}
\IfFileExists{\@tmpdir#2.\@outext}{ % the postscript/pdf exists: include it
\ifpsfrag
% per the ladot 2.2 source code, psfrag has a problem with
% graphviz 2.2, and some sed hackery is necessary to work around
\write18{sed -ibackup -e "s/xshow/pop show/g" \@tmpdir#2.ps}
\fi
\includegraphics[#1]{\@tmpdir#2.\@outext}
}
% else: the postscript/pdf doesn't exist: tell the user how to create it
{
\fbox{ \begin{tabular}{l}
The file \texttt{#2.\@outext} hasn't been created from
\texttt{\@tmpdir#2.dot} yet. \\
Run `\texttt{dot -T\@outextspace -o \@tmpdir#2.\@outextspace \@tmpdir#2.dot}'
to create it. \\
Or invoke \LaTeX\ with the \texttt{-shell-escape} option
to have this done automatically. \\
\end{tabular}}
}
}
\endinput
%%
%% End of file `graphviz.sty'.
|