Debian Codegraph @

texmf-dist/tex/latex/dottex/dottex.sty

raw
1 %%
2 %% This is file `dottex.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% dottex.dtx (with options: `package')
8 %%
9 %% Copyright (c) 2005, Lars Kotthoff <[email protected]>
10 %%
11 %% Large portions copied from pdftex,
12 %% Copyright (c) 2001-3, Radhakrishnan CV <[email protected]>
13 %% Rajagopal CV <[email protected]>
14 %% http://www.river-valley.com
15 %%
16 %% River Valley Technologies, Floor III, SJP Buildings, Cotton Hills
17 %% Trivandrum, India 695014
18 %%
19 %% Tel: +91 471 233 7501
20 %%
21 %% Antoine Chambert-Loir
22 %% <[email protected]>
23 %% http://www.math.polytechnique.fr/\protect \unhbox \voidb@x \penalty \@M \ {}chambert
24 %%
25 %% Ecole polytechnique, Palaiseau Cedex, France
26 %%
27 %% This program is free software; you can redistribute it and/or
28 %% modify it under the terms of the GNU General Public License
29 %% as published by the Free Software Foundation; either version 2
30 %% of the License, or (at your option) any later version.
31 %%
32 %% This program is distributed in the hope that it will be useful,
33 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
34 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 %% GNU General Public License for more details.
36 %%
37 %% You should have received a copy of the GNU General Public License
38 %% along with this program (gpl.txt); if not, write to the Free
39 %% Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
40 %% MA 02111-1307, USA.
41 %%
42 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
43 \ProvidesPackage{dottex}
44 [2007/08/22 v0.6 dot/neato graphs in LaTeX]
45 \RequirePackage{graphicx,moreverb,keyval}
46 \newif\ifShellEscape
47 \newif\ifmiktex \miktexfalse
48 \newif\ifpdf \pdffalse
49
50 \DeclareOption{shell}{\ShellEscapetrue}
51 \DeclareOption{noshell}{\ShellEscapefalse}
52 \DeclareOption{miktex}{\global\miktextrue}
53 \DeclareOption{pdf}{\pdftrue}
54
55 \ExecuteOptions{shell}
56 \ProcessOptions\relax
57 %% test if shell escape really works
58 \ifShellEscape
59 \def\tmpfile{/tmp/w18-test-\the\year\the\month\the\day\the\time}
60 \ifmiktex
61 \def\tmpfile{w18-test-\the\year\the\month\the\day\the\time}
62 \immediate\write18{echo t > "\tmpfile"}
63 \else
64 \immediate\write18{touch \tmpfile}
65 \fi
66 \ifmiktex
67 \IfFileExists{\tmpfile.}{\ShellEscapetrue}{\ShellEscapefalse}
68 \immediate\write18{del "\tmpfile"}
69 \else
70 \IfFileExists{\tmpfile}{\ShellEscapetrue}{\ShellEscapefalse}
71 \immediate\write18{rm -f \tmpfile}
72 \fi
73 \fi
74
75 \ifShellEscape
76 \PackageInfo{dottex}
77 {Automatically converting dot/neato files}
78 \else
79 \PackageWarningNoLine{dottex}
80 {Shell escape not enabled.\MessageBreak
81 You'll need to convert the graphs yourself.}
82 \fi
83 \newcounter{fignum}
84 \def\figname{\jobname-dottex-fig\thefignum}
85
86 \def\dotverbatimwrite#1{%
87 \def\BeforeStream
88 {\message{Opening Dot stream=\figname.dot}%
89 \immediate\write\verbatim@out{\string digraph\space G\space {/*}*/}
90 }
91 \@bsphack
92 \immediate\openout \verbatim@out #1
93 \BeforeStream%
94 \let\do\@makeother\dospecials
95 \catcode`\^^M\active
96 \def\verbatim@processline{%
97 \immediate\write\verbatim@out
98 {\the\verbatim@line}}%
99 \verbatim@start}
100 \def\enddotverbatimwrite{%
101 \immediate\write\verbatim@out{/*{*/}}
102 \immediate\closeout\verbatim@out
103 \@esphack}
104
105 \def\neatoverbatimwrite#1{%
106 \def\BeforeStream
107 {\message{Opening Neato stream=\figname.neato}%
108 \immediate\write\verbatim@out{\string graph\space G\space {/*}*/}
109 }
110 \@bsphack
111 \immediate\openout \verbatim@out #1
112 \BeforeStream%
113 \let\do\@makeother\dospecials
114 \catcode`\^^M\active
115 \def\verbatim@processline{%
116 \immediate\write\verbatim@out
117 {\the\verbatim@line}}%
118 \verbatim@start}
119 \def\endneatoverbatimwrite{%
120 \immediate\write\verbatim@out{/*{*/}}
121 \immediate\closeout\verbatim@out
122 \@esphack}
123 \define@key{pic}{width}{\def\dotwidth{#1}}
124 \define@key{pic}{height}{\def\dotheight{#1}}
125 \newenvironment{dotpic}[1][]{\stepcounter{fignum}%
126 \let\dotwidth\undefined
127 \let\dotheight\undefined
128 \setkeys{pic}{#1}
129 \xdef\dotCutFile{\figname.dot}
130 \dotverbatimwrite{\dotCutFile}}
131 {\enddotverbatimwrite%
132 \dotgraphicsinclude}
133
134 \newenvironment{neatopic}[1][]{\stepcounter{fignum}%
135 \let\dotwidth\undefined
136 \let\dotheight\undefined
137 \setkeys{pic}{#1}
138 \xdef\neatoCutFile{\figname.neato}
139 \neatoverbatimwrite{\neatoCutFile}}
140 {\endneatoverbatimwrite%
141 \neatographicsinclude}
142 \long\gdef\dotgraphicsprocess{%
143 \ifShellEscape
144 \IfFileExists{\figname.dot}{%
145 \immediate\write18{dot -Tps2 -o \figname.ps \figname.dot}
146 \IfFileExists{\figname.ps}{%
147 \ifpdf
148 \immediate\write18{ps2pdf \figname.ps \figname.pdf}
149 \IfFileExists{\figname.pdf}{%
150 \PackageInfo{dottex}
151 {\figname.dot converted}}
152 {\PackageWarningNoLine{dottex}
153 {Conversion of \figname.dot failed.}}
154 \else
155 \PackageInfo{dottex}
156 {\figname.dot converted}
157 \fi}
158 {\PackageWarningNoLine{dottex}
159 {Conversion of \figname.dot failed.}}}{}
160 \fi}
161
162 \long\gdef\neatographicsprocess{%
163 \ifShellEscape
164 \IfFileExists{\figname.neato}{%
165 \immediate\write18{neato -Tps2 -o \figname.ps \figname.neato}
166 \IfFileExists{\figname.ps}{%
167 \ifpdf
168 \immediate\write18{ps2pdf \figname.ps \figname.pdf}
169 \IfFileExists{\figname.pdf}{%
170 \PackageInfo{dottex}
171 {\figname.dot converted}}
172 {\PackageWarningNoLine{dottex}
173 {Conversion of \figname.dot failed.}}
174 \else
175 \PackageInfo{dottex}
176 {\figname.neato converted}
177 \fi}
178 {\PackageWarningNoLine{dottex}
179 {Conversion of \figname.neato failed.}}}{}
180 \fi}
181 \long\gdef\dotgraphicsinclude{\dotgraphicsprocess%
182 \ifpdf
183 \IfFileExists{\figname.pdf}{%
184 \ifx\dotwidth\undefined
185 \ifx\dotheight\undefined
186 \includegraphics{\figname}
187 \else
188 \includegraphics[height=\dotheight]{\figname}
189 \fi
190 \else
191 \ifx\dotheight\undefined
192 \includegraphics[width=\dotwidth]{\figname}
193 \else
194 \includegraphics[width=\dotwidth,height=\dotheight]{\figname}
195 \fi
196 \fi
197 }
198 {\PackageWarningNoLine{dottex}
199 {Please convert \figname.dot manually}}
200 \else
201 \IfFileExists{\figname.ps}{%
202 \ifx\dotwidth\undefined
203 \ifx\dotheight\undefined
204 \includegraphics{\figname}
205 \else
206 \includegraphics[height=\dotheight]{\figname}
207 \fi
208 \else
209 \ifx\dotheight\undefined
210 \includegraphics[width=\dotwidth]{\figname}
211 \else
212 \includegraphics[width=\dotwidth,height=\dotheight]{\figname}
213 \fi
214 \fi
215 }
216 {\PackageWarningNoLine{dottex}
217 {Please convert \figname.dot manually}}
218 \fi
219 }
220
221 \long\gdef\neatographicsinclude{\neatographicsprocess%
222 \ifpdf
223 \IfFileExists{\figname.pdf}{%
224 \ifx\dotwidth\undefined
225 \ifx\dotheight\undefined
226 \includegraphics{\figname}
227 \else
228 \includegraphics[height=\dotheight]{\figname}
229 \fi
230 \else
231 \ifx\dotheight\undefined
232 \includegraphics[width=\dotwidth]{\figname}
233 \else
234 \includegraphics[width=\dotwidth,height=\dotheight]{\figname}
235 \fi
236 \fi
237 }
238 {\PackageWarningNoLine{dottex}
239 {Please convert \figname.neato manually}}
240 \else
241 \IfFileExists{\figname.ps}{%
242 \ifx\dotwidth\undefined
243 \ifx\dotheight\undefined
244 \includegraphics{\figname}
245 \else
246 \includegraphics[height=\dotheight]{\figname}
247 \fi
248 \else
249 \ifx\dotheight\undefined
250 \includegraphics[width=\dotwidth]{\figname}
251 \else
252 \includegraphics[width=\dotwidth,height=\dotheight]{\figname}
253 \fi
254 \fi
255 }
256 {\PackageWarningNoLine{dottex}
257 {Please convert \figname.neato manually}}
258 \fi
259 }
260 \endinput
261 %%
262 %% End of file `dottex.sty'.