Debian Codegraph @

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

raw
1 %%
2 %% This is file `combinedgraphics.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% combinedgraphics.dtx (with options: `package')
8 %%
9 %% This is a generated file.
10 %%
11 %% Copyright 2009 Christian Schneider <software(at)chschneider(dot)eu>
12 %%
13 %% ion@addto@macro: identical to l@addto@macro from koma-script
14 %% bundle v2.9t
15 %% Copyright 1994-2004 Markus Kohm and Frank Neukam
16 %%
17 %% Thanks to Markus Kohm for permitting to use his code in this package.
18 %% Please do not bother Markus with questions or bugs concering this package!
19 %%
20 %% This file is part of combinedgraphics.
21 %%
22 %% combinedgraphics is free software: you can redistribute it and/or modify
23 %% it under the terms of the GNU General Public License version 3 as
24 %% published by the Free Software Foundation, not any later version.
25 %%
26 %% combinedgraphics is distributed in the hope that it will be useful,
27 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
28 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 %% GNU General Public License for more details.
30 %%
31 %% You should have received a copy of the GNU General Public License
32 %% along with combinedgraphics. If not, see <http://www.gnu.org/licenses/>.
33 %%
34 %% WARNING: THIS IS ALPHA SOFTWARE AND MAY CONTAIN SERIOUS BUGS!
35 %%
36 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
37 \ProvidesPackage{combinedgraphics}
38 [2012/07/13 v0.2.2 inclusion of combined EPS/LaTeX graphics]
39 \RequirePackage{keyval}
40 \RequirePackage{graphicx}
41 \RequirePackage{color}
42 \newif\ifcgr@vecfirst
43 \def\cgr@vecscale@type{0}
44 \newcommand*\cgr@defopts{\define@key{cgr}}
45 \newcommand*\cgr@setopts{\setkeys{cgr}}
46 \cgr@defopts{textfontcmd}{\gdef\cgr@textfont@default{\@nameuse{#1}}}
47 \cgr@defopts{textcolorcmd}{\gdef\cgr@textcolor@default{\@nameuse{#1}}}
48 \cgr@defopts{vecscale}{\gdef\cgr@vecscale@default{#1}%
49 \gdef\cgr@vecscale@type{0}}
50 \cgr@defopts{vecwidth}{\gdef\cgr@vecwidth@default{#1}%
51 \gdef\cgr@vecscale@type{1}}
52 \cgr@defopts{vecheight}{\gdef\cgr@vecheight@default{#1}%
53 \gdef\cgr@vecscale@type{2}}
54 \cgr@defopts{vecinclude}{\gdef\cgr@vecinclude@default{#1}}
55 \cgr@defopts{vecfirst}{\gdef\cgr@vecfirst@default{#1}}
56 \DeclareOption*{%
57 \expandafter\cgr@setopts\expandafter{\CurrentOption}%
58 }
59 \ProcessOptions\relax
60 \newcommand*\cgr@defopts@combgrphcs{\define@key{cgr@combgrphcs}}
61 \newcommand*\cgr@setopts@combgrphcs{\setkeys{cgr@combgrphcs}}
62 \cgr@defopts@combgrphcs{textfont}{%
63 \def\@tempa{#1}%
64 \ifx\@tempa\@empty%
65 \def\cgr@textfont{}%
66 \else%
67 \def\cgr@textfont{%
68 #1%
69 \def\SetFigFont{\cgr@gobblefive}% %% Xfig <= 3.2.4
70 \def\SetFigFontNFSS{\cgr@gobblefive}% %% Xfig >= 3.2.5-alpha
71 }%
72 \fi%
73 }
74 \cgr@defopts@combgrphcs{textcolor}{%
75 \def\@tempa{#1}%
76 \ifx\@tempa\@empty%
77 \def\cgr@textcolor{}%
78 \else%
79 \def\cgr@textcolor{%
80 #1%
81 \def\color{\cgr@gobble@optone}%
82 }%
83 \fi%
84 }
85 \cgr@defopts@combgrphcs{vecscale}{%
86 \def\cgr@vecscale{#1}%
87 \def\setlength{\cgr@setlength}%
88 \def\includegraphics{\cgr@includegraphics}%
89 }
90 \cgr@defopts@combgrphcs{vecwidth}{%
91 \cgr@vecscale@wd{\cgr@texfile}{\cgr@vecfile}{#1}%
92 \def\setlength{\cgr@setlength}%
93 \def\includegraphics{\cgr@includegraphics}%
94 }
95 \cgr@defopts@combgrphcs{vecheight}{%
96 \cgr@vecscale@ht{\cgr@texfile}{\cgr@vecfile}{#1}%
97 \def\setlength{\cgr@setlength}%
98 \def\includegraphics{\cgr@includegraphics}%
99 }
100 \cgr@defopts@combgrphcs{vecinclude}{%
101 \def\cgr@vecinclude{\@nameuse{cgr@requires@graphics#1}}%
102 }
103 \cgr@defopts@combgrphcs{vecfirst}{%
104 \@nameuse{cgr@vecfirst#1}%
105 }
106 \cgr@defopts@combgrphcs{vecfile}{%
107 \def\cgr@vecfile{#1}%
108 \cgr@setopts@combgrphcs{vecinclude=overwrite}%
109 }
110 \cgr@defopts@combgrphcs{angle}{%
111 \ifx\cgr@curr@scaleopts\@empty%
112 \cgr@raddto@macro[groupfirst]{\cgr@curr@pic}{\rotatebox{#1}}%
113 \else%
114 \cgr@raddto@macro[groupfirst]{\cgr@curr@pic}{]}%
115 \cgr@raddto@macro[expand]{\cgr@curr@pic}{\cgr@curr@scaleopts}%
116 \cgr@raddto@macro{\cgr@curr@pic}{\rotatebox[}%
117 \def\cgr@curr@scaleopts{}%
118 \fi%
119 }
120 \cgr@defopts@combgrphcs{origin}{\cgr@addto@macro{\cgr@curr@scaleopts}{%
121 origin=#1,}%
122 }
123 \cgr@defopts@combgrphcs{x}{\cgr@addto@macro{\cgr@curr@scaleopts}{x=#1,}}
124 \cgr@defopts@combgrphcs{y}{\cgr@addto@macro{\cgr@curr@scaleopts}{y=#1,}}
125 \cgr@defopts@combgrphcs{units}{\cgr@addto@macro{\cgr@curr@scaleopts}{units=#1,}}
126 \cgr@defopts@combgrphcs{scale}{%
127 \cgr@raddto@macro[groupfirst]{\cgr@curr@pic}{\scalebox{#1}}%
128 }
129 \cgr@defopts@combgrphcs{hscale}{%
130 \def\cgr@curr@hscale{#1}%
131 \ifx\cgr@curr@vscale\@empty%
132 \else%
133 \cgr@raddto@macro[groupfirst]{\cgr@curr@pic}{]}%
134 \cgr@raddto@macro[expand]{\cgr@curr@pic}{\cgr@curr@vscale}%
135 \cgr@raddto@macro{\cgr@curr@pic}{[}%
136 \cgr@raddto@macro[expand,groupsecond]{\cgr@curr@pic}{\cgr@curr@hscale}%
137 \cgr@raddto@macro{\cgr@curr@pic}{\scalebox}%
138 \def\cgr@curr@hscale{}%
139 \def\cgr@curr@vscale{}%
140 \fi%
141 }
142 \cgr@defopts@combgrphcs{vscale}{%
143 \def\cgr@curr@vscale{#1}%
144 \ifx\cgr@curr@hscale\@empty%
145 \else%
146 \cgr@raddto@macro[groupfirst]{\cgr@curr@pic}{]}%
147 \cgr@raddto@macro[expand]{\cgr@curr@pic}{\cgr@curr@vscale}%
148 \cgr@raddto@macro{\cgr@curr@pic}{[}%
149 \cgr@raddto@macro[expand,groupsecond]{\cgr@curr@pic}{\cgr@curr@hscale}%
150 \cgr@raddto@macro{\cgr@curr@pic}{\scalebox}%
151 \def\cgr@curr@hscale{}%
152 \def\cgr@curr@vscale{}%
153 \fi%
154 }
155 \cgr@defopts@combgrphcs{height}{%
156 \def\cgr@curr@height{#1}%
157 \ifx\cgr@curr@width\@empty%
158 \else%
159 \cgr@raddto@macro[groupfirst,groupsecond,expand]{\cgr@curr@pic}{%
160 \cgr@curr@height%
161 }%
162 \cgr@raddto@macro[groupsecond,expand]{\cgr@curr@pic}{\cgr@curr@width}%
163 \cgr@raddto@macro{\cgr@curr@pic}{\resizebox}%
164 \def\cgr@curr@height{}%
165 \def\cgr@curr@width{}%
166 \fi%
167 }
168 \cgr@defopts@combgrphcs{totalheight}{%
169 \def\cgr@curr@totalheight{#1}%
170 \ifx\cgr@curr@width\@empty%
171 \else%
172 \cgr@raddto@macro[groupfirst,groupsecond,expand]{\cgr@curr@pic}{%
173 \cgr@curr@totalheight%
174 }%
175 \cgr@raddto@macro[groupsecond,expand]{\cgr@curr@pic}{\cgr@curr@width}%
176 \cgr@raddto@macro{\cgr@curr@pic}{\resizebox*}%
177 \def\cgr@curr@totalheight{}%
178 \def\cgr@curr@width{}%
179 \fi%
180 }
181 \cgr@defopts@combgrphcs{width}{%
182 \def\cgr@curr@width{#1}%
183 \ifx\cgr@curr@height\@empty%
184 \ifx\cgr@curr@totalheight\@empty%
185 \else%
186 \cgr@raddto@macro[groupfirst,groupsecond,expand]{\cgr@curr@pic}{%
187 \cgr@curr@totalheight%
188 }%
189 \cgr@raddto@macro[groupsecond,expand]{\cgr@curr@pic}{\cgr@curr@width}%
190 \cgr@raddto@macro{\cgr@curr@pic}{\resizebox*}%
191 \def\cgr@curr@totalheight{}%
192 \def\cgr@curr@width{}%
193 \fi%
194 \else%
195 \cgr@raddto@macro[groupfirst,groupsecond,expand]{\cgr@curr@pic}{%
196 \cgr@curr@height%
197 }%
198 \cgr@raddto@macro[groupsecond,expand]{\cgr@curr@pic}{\cgr@curr@width}%
199 \cgr@raddto@macro{\cgr@curr@pic}{\resizebox}%
200 \def\cgr@curr@height{}%
201 \def\cgr@curr@totalheight{}%
202 \def\cgr@curr@width{}%
203 \fi%
204 }
205 \cgr@defopts@combgrphcs{keepaspectratio}[]{%
206 \ifx\cgr@curr@height\@empty%
207 \ifx\cgr@curr@totalheight\@empty%
208 \ifx\cgr@curr@width\@empty%
209 \else%
210 \cgr@setopts@combgrphcs{height=!}%
211 \fi%
212 \else%
213 \cgr@setopts@combgrphcs{width=!}%
214 \fi%
215 \else%
216 \cgr@setopts@combgrphcs{width=!}%
217 \def\cgr@curr@totalheight{}%
218 \fi%
219 }
220 \long\def\cgr@curr@pic{}
221 \newif\ifcgr@requires@graphics\cgr@requires@graphicstrue
222 \def\cgr@requires@graphicsauto{}
223 \def\cgr@requires@graphicsoverwrite{%
224 \cgr@requires@graphicstrue%
225 \def\includegraphics{\cgr@gobble@optone}%
226 }
227 \def\cgr@textfont{}
228 \def\cgr@textcolor{}
229 \def\cgr@vecscale{1}
230 \def\cgr@vecinclude{\cgr@requires@graphicsauto}
231 \cgr@vecfirsttrue
232 \def\cgr@texfile{}
233 \def\cgr@vecfile{}
234 \def\cgr@curr@hscale{}
235 \def\cgr@curr@vscale{}
236 \def\cgr@curr@scaleopts{}
237 \def\cgr@curr@height{}
238 \def\cgr@curr@width{}
239 \def\cgr@curr@totalheight{}
240 \newcommand{\includecombinedgraphics}[2][]{%
241 \begingroup%
242 \global\cgr@requires@graphicstrue%
243 \setbox\@tempboxa\hbox{%
244 \def\includegraphics{%
245 \global\cgr@requires@graphicsfalse\cgr@gobble@optone%
246 }%
247 \input{#2}%
248 }%
249 \cgr@addto@macro{\cgr@curr@pic}{%
250 %% from basic macro options
251 \cgr@vecinclude\cgr@textfont\cgr@textcolor%
252 %% inclusion of vector graphics part
253 \ifcgr@requires@graphics%
254 \ifcgr@vecfirst%
255 \begin{picture}(0,0)%
256 \cgr@includegraphics@orig[scale=\cgr@vecscale]{\cgr@vecfile}%
257 \end{picture}%
258 \else%
259 \def\picture{\cgr@picture}%
260 \def\endpicture{%
261 \put(\cgr@picture@xoffs,\cgr@picture@yoffs)%
262 {\cgr@includegraphics@orig[scale=\cgr@vecscale]{\cgr@vecfile}}%
263 \cgr@endpicture@orig%
264 }%
265 \fi%
266 \fi%
267 %% inclusion of \LaTeX{} part
268 \input{#2}%
269 }%
270 \def\cgr@vecfile{#2}%
271 \def\cgr@texfile{#2}%
272 \if0\cgr@vecscale@type%
273 \@ifundefined{cgr@vecscale@default}{}{%
274 \cgr@setopts@combgrphcs{vecscale=\cgr@vecscale@default}%
275 }%
276 \fi%
277 \if1\cgr@vecscale@type%
278 \@ifundefined{cgr@vecwidth@default}{}{%
279 \cgr@setopts@combgrphcs{vecwidth=\cgr@vecwidth@default}%
280 }%
281 \fi%
282 \if2\cgr@vecscale@type%
283 \@ifundefined{cgr@vecheight@default}{}{%
284 \cgr@setopts@combgrphcs{vecheight=\cgr@vecheight@default}%
285 }%
286 \fi%
287 \@ifundefined{cgr@textfont@default}{}{%
288 \cgr@setopts@combgrphcs{textfont=\cgr@textfont@default}%
289 }%
290 \@ifundefined{cgr@textcolor@default}{}{%
291 \cgr@setopts@combgrphcs{textcolor=\cgr@textcolor@default}%
292 }%
293 \@ifundefined{cgr@vecinclude@default}{}{%
294 \cgr@setopts@combgrphcs{vecinclude=\cgr@vecinclude@default}%
295 }%
296 \@ifundefined{cgr@vecfirst@default}{}{%
297 \cgr@setopts@combgrphcs{vecfirst=\cgr@vecfirst@default}%
298 }%
299 \cgr@setopts@combgrphcs{#1}%
300 \cgr@curr@pic%
301 \endgroup%
302 }
303 \long\def\cgr@gobblefive#1#2#3#4#5{}
304 \long\def\cgr@gobble@optone{\@ifstar{\cgr@gobble@optone}{\cgr@gobble@optone@}}
305 \long\def\cgr@gobble@optone@{\@ifnextchar [{\cgr@gobble@optone@@}{\@gobble}}
306 \long\def\cgr@gobble@optone@@[#1]{\cgr@gobble@optone@}
307 \let\cgr@setlength@orig=\setlength
308 \def\cgr@setlength#1#2{%
309 \ifx#1\unitlength%
310 \@tempdima=#2%
311 \cgr@setlength@orig{#1}{\cgr@vecscale\@tempdima}%
312 \def\setlength{\cgr@setlength@orig}%
313 \else%
314 \cgr@setlength@orig{#1}{#2}%
315 \fi%
316 }
317 \let\cgr@includegraphics@orig=\includegraphics
318 \def\cgr@includegraphics{%
319 \@ifstar{%
320 \cgr@includegraphics@s@%
321 }{%
322 \cgr@includegraphics@%
323 }%
324 }
325 \def\cgr@includegraphics@{%
326 \@ifnextchar [{%
327 \cgr@includegraphics@@%
328 }{%
329 \cgr@includegraphics@orig[scale=\cgr@vecscale]%
330 }%
331 }
332 \def\cgr@includegraphics@@[#1]{%
333 \@ifnextchar [{%
334 \cgr@includegraphics@@@[#1]%
335 }{%
336 \cgr@includegraphics@orig[#1,scale=\cgr@vecscale]%
337 }%
338 }
339 \def\cgr@includegraphics@@@[#1][#2]{%
340 \cgr@includegraphics@orig[#1][#2,scale=\cgr@vecscale]%
341 }
342 \def\cgr@includegraphics@s@{%
343 \@ifnextchar [{%
344 \cgr@includegraphics@s@@%
345 }{%
346 \cgr@includegraphics@orig*[scale=\cgr@vecscale]%
347 }%
348 }
349 \def\cgr@includegraphics@s@@[#1]{%
350 \@ifnextchar [{%
351 \cgr@includegraphics@s@@@[#1]%
352 }{%
353 \cgr@includegraphics@orig*[#1,scale=\cgr@vecscale]%
354 }%
355 }
356 \def\cgr@includegraphics@s@@@[#1][#2]{%
357 \cgr@includegraphics@orig*[#1][#2,scale=\cgr@vecscale]%
358 }
359 \let\cgr@picture@orig=\picture
360 \let\cgr@endpicture@orig=\endpicture
361 \long\def\cgr@picture(#1,#2){%
362 \@ifnextchar({%
363 \cgr@picture@(#1,#2)%
364 }{%
365 \cgr@picture@(#1,#2)(0,0)%
366 }%
367 }
368 \def\cgr@picture@(#1,#2)(#3,#4){%
369 \def\cgr@picture@xoffs{#3}%
370 \def\cgr@picture@yoffs{#4}%
371 \cgr@picture@orig(#1,#2)(#3,#4)%
372 }
373 \newcommand{\cgr@addto@macro}[2]{%
374 \begingroup\toks@\expandafter{#1#2}%
375 \edef\@tempa{\endgroup\def\noexpand#1{\the\toks@}}%
376 \@tempa%
377 }
378 \newcommand*\cgr@defopts@raddto{\define@key{cgr@raddto}}
379 \newcommand*\cgr@setopts@raddto{\setkeys{cgr@raddto}}
380 \newif\ifcgr@raddto@expand\cgr@raddto@expandfalse
381 \newif\ifcgr@raddto@groupfirst\cgr@raddto@groupfirstfalse
382 \newif\ifcgr@raddto@groupsecond\cgr@raddto@groupsecondfalse
383 \cgr@defopts@raddto{expand}[true]{\@nameuse{cgr@raddto@expand#1}}
384 \cgr@defopts@raddto{groupfirst}[true]{\@nameuse{cgr@raddto@groupfirst#1}}
385 \cgr@defopts@raddto{groupsecond}[true]{\@nameuse{cgr@raddto@groupsecond#1}}
386 \newtoks\cgr@token@a
387 \newtoks\cgr@token@b
388 \newcommand{\cgr@raddto@macro}[3][]{%
389 \begingroup%
390 \cgr@setopts@raddto{#1}%
391 \cgr@token@a\expandafter{#2}%
392 \ifcgr@raddto@expand%
393 \cgr@token@b\expandafter{#3}%
394 \else%
395 \cgr@token@b{#3}%
396 \fi%
397 \ifcgr@raddto@groupfirst%
398 \ifcgr@raddto@groupsecond%
399 \edef\@tempa{\endgroup%
400 \def\noexpand#2{{\the\cgr@token@b}{\the\cgr@token@a}}%
401 }%
402 \else%
403 \edef\@tempa{\endgroup%
404 \def\noexpand#2{\the\cgr@token@b{\the\cgr@token@a}}%
405 }%
406 \fi%
407 \else%
408 \ifcgr@raddto@groupsecond%
409 \edef\@tempa{\endgroup%
410 \def\noexpand#2{{\the\cgr@token@b}\the\cgr@token@a}%
411 }%
412 \else%
413 \edef\@tempa{\endgroup%
414 \def\noexpand#2{\the\cgr@token@b\the\cgr@token@a}%
415 }%
416 \fi%
417 \fi%
418 \@tempa%
419 }
420 \newcount\cgr@tempdigit
421 \newcommand*\cgr@vecscale@wd[3]{%
422 \cgr@vecscale@graphicsbox{#1}{#2}%
423 \cgr@vecscale@calc{\wd\@tempboxa}{#3}%
424 }
425 \newcommand*\cgr@vecscale@ht[3]{%
426 \cgr@vecscale@graphicsbox{#1}{#2}%
427 \@tempdimc=\ht\@tempboxa%
428 \advance\@tempdimc by\dp\@tempboxa%
429 \cgr@vecscale@calc{\@tempdimc}{#3}%
430 }
431 \newcommand*\cgr@vecscale@graphicsbox[2]{%
432 \setbox\@tempboxa\hbox{%
433 \begingroup%
434 \def\setlength{\cgr@setlength@orig}%
435 \def\includegraphics{\cgr@gobble@optone}%
436 \input{#1}%
437 \endgroup%
438 }%
439 }
440 \newcommand*\cgr@vecscale@calc[2]{%
441 \@tempdimb=#1%
442 \@tempcntb=\@tempdimb%
443 \@tempdima=#2%
444 \@tempcnta=\@tempdima%
445 \cgr@tempdigit=\@tempcnta%
446 \divide\cgr@tempdigit by\@tempcntb%
447 \edef\cgr@vecscale{\the\cgr@tempdigit.}%
448 \cgr@next@digit\cgr@next@digit\cgr@next@digit%
449 \cgr@next@digit\cgr@next@digit\cgr@next@digit%
450 }
451 \newcommand*\cgr@next@digit{%
452 \multiply\cgr@tempdigit by\@tempcntb%
453 \advance\@tempcnta by-\cgr@tempdigit%
454 \multiply\@tempcnta by10%
455 \cgr@tempdigit=\@tempcnta%
456 \divide\cgr@tempdigit by\@tempcntb%
457 \edef\cgr@vecscale{\cgr@vecscale\the\cgr@tempdigit}%
458 }
459 \endinput
460 %%
461 %% End of file `combinedgraphics.sty'.