Debian Codegraph @

latex/style/dbk_graphic.sty

raw
1 %
2 % Check if the image file (#1) exists. If so, it switches to #2, else to #3
3 % It assumes that the graphics package \Gin@extensions macro is defined.
4 %
5 \long\def\imgexists#1#2#3{%
6 \begingroup%
7 \let\img@file\relax%
8 \filename@parse{#1}%
9 \ifx\filename@ext\relax%
10 \@for\Gin@temp:=\Gin@extensions\do{%
11 \ifx\img@file\relax%
12 \IfFileExists{#1\Gin@temp}{\def\img@file{#1}}{}%
13 \fi}%
14 \else
15 \IfFileExists{#1}{\def\img@file{#1}}{}%
16 \fi%
17 \ifx\img@file\relax#3\else#2\fi%
18 \endgroup%
19 }
20
21 %
22 % The image keeps its natural size if lower than the max boundaries
23 % Now it's fully based on internal graphics macros
24 %
25 % Macros defining the maximum lengths
26 \def\imgmaxwidth{\textwidth}
27 \def\imgmaxheight{\textheight}
28
29 % Real image sizes
30 \def\imgrwidth{\Gin@nat@width}
31 \def\imgrheight{\Gin@nat@height}
32 \def\imgevalsize#1{}%
33
34 % Use the maximum possible size
35 \def\imgwidth{%
36 \ifdim\Gin@nat@width>\imgmaxwidth
37 \imgmaxwidth
38 \else
39 \Gin@nat@width
40 \fi
41 }
42
43 \def\imgheight{%
44 \ifdim\Gin@nat@height>\imgmaxheight
45 \imgmaxheight
46 \else
47 \Gin@nat@height
48 \fi
49 }
50