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