Debian Codegraph @

texmf-dist/tex/latex/lwarp/lwarp-graphics.sty

raw
1 %%
2 %% This is file `lwarp-graphics.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% lwarp.dtx (with options: `graphics')
8 %% This is a generated file.
9 %% Copyright 2016-2026 Brian Dunn
10 %%
11 %% This work may be distributed and/or modified under the
12 %% conditions of the LaTeX Project Public License, either version 1.3
13 %% of this license or (at your option) any later version.
14 %% The latest version of this license is in
15 %% http://www.latex-project.org/lppl.txt
16 %% and version 1.3 or later is part of all distributions of LaTeX
17 %% version 2005/12/01 or later.
18
19
20 \LWR@ProvidesPackagePass{graphics}[2024/08/06]
21
22
23 \AtBeginDocument{
24 \DeclareGraphicsExtensions{.svg,.SVG,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG}
25 \DeclareGraphicsRule{.svg}{svg}{.svg}{}
26 \DeclareGraphicsRule{.SVG}{svg}{.SVG}{}
27 }
28 \ifpdf
29 \appto\LWR@restoreorigformatting{%
30 \DeclareGraphicsExtensions{.pdf,.PDF,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG}%
31 }
32 \else% \ifpdf
33 \ifXeTeX
34 \appto\LWR@restoreorigformatting{%
35 \DeclareGraphicsExtensions{.pdf,.PDF,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG}%
36 }
37 \else
38 \appto\LWR@restoreorigformatting{%
39 \DeclareGraphicsExtensions{.eps,.EPS,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG}%
40 }
41 \fi
42 \fi
43
44
45 \newlength{\LWR@igwidth}
46 \newlength{\LWR@igheight}
47 \newcommand*{\LWR@igwidthstyle}{}
48 \newcommand*{\LWR@igheightstyle}{}
49 \newcommand*{\LWR@igorigin}{}
50 \newcommand*{\LWR@igangle}{}
51 \newcommand*{\LWR@igxscale}{1}
52 \newcommand*{\LWR@igyscale}{1}
53
54 \newbool{LWR@igkeepaspectratio}
55 \boolfalse{LWR@igkeepaspectratio}
56
57 \newcommand*{\LWR@igclass}{inlineimage}
58
59 \define@key{igraph}{width}{%
60 \setlength{\LWR@igwidth}{#1}%
61 \ifthenelse{\lengthtest{\LWR@igwidth > 0pt}}%
62 {%
63 \renewcommand*{\LWR@igwidthstyle}{width:\LWR@printlength{\LWR@igwidth}}%
64 \IfEndWith{#1}{ex}%
65 {\renewcommand*{\LWR@igwidthstyle}{width:#1}}% yes ex
66 {}% not ex
67 \IfEndWith{#1}{em}%
68 {\renewcommand*{\LWR@igwidthstyle}{width:#1}}% yes em
69 {}% not em
70 \IfEndWith{#1}{\%}%
71 {\renewcommand*{\LWR@igwidthstyle}{width:#1}}% yes percent
72 {}% not percent
73 \IfEndWith{#1}{px}%
74 {\renewcommand*{\LWR@igwidthstyle}{width:#1}}% yes px
75 {}% not px
76 }{}% end of length > 0pt
77 }
78 \define@key{igraph}{height}{%
79 \setlength{\LWR@igheight}{#1}%
80 \ifthenelse{\lengthtest{\LWR@igheight > 0pt}}%
81 {%
82 \renewcommand*{\LWR@igheightstyle}{%
83 height:\LWR@printlength{\LWR@igheight} % extra space
84 }%
85 \IfEndWith{#1}{ex}%
86 {\renewcommand*{\LWR@igheightstyle}{height:#1}}% yes ex
87 {}% not ex
88 \IfEndWith{#1}{em}%
89 {\renewcommand*{\LWR@igheightstyle}{height:#1}}% yes em
90 {}% not em
91 \IfEndWith{#1}{\%}%
92 {\renewcommand*{\LWR@igheightstyle}{height:#1}}% yes percent
93 {}% not percent
94 \IfEndWith{#1}{px}%
95 {\renewcommand*{\LWR@igheightstyle}{height:#1}}% yes px
96 {}% not px
97 }{}% end of length > 0pt
98 }
99 \define@key{igraph}{keepaspectratio}[false]{%
100 \booltrue{LWR@igkeepaspectratio}%
101 }
102 \define@key{igraph}{origin}[c]{%
103 \renewcommand*{\LWR@igorigin}{#1}%
104 }
105 \define@key{igraph}{angle}{\renewcommand*{\LWR@igangle}{#1}}
106 \define@key{igraph}{class}{\renewcommand*{\LWR@igclass}{#1}}
107 \define@key{igraph}{alt}{\renewcommand*{\LWR@ThisAltText}{#1}}
108 \define@key{igraph}{actualtext}{\renewcommand*{\LWR@ThisAltText}{#1}}
109 \define@key{igraph}{artifact}[false]{}
110 \define@key{igraph}{scale}{%
111 \ifthenelse{\equal{#1}{1}}{}{% must expand #1
112 \PackageNote{lwarp}{%
113 It is recommended to use ``[width=xx\protect\linewidth]''\MessageBreak
114 instead of ``[scale=yy]'',%
115 }%
116 }%
117 \renewcommand*{\LWR@igxscale}{#1}%
118 \renewcommand*{\LWR@igyscale}{#1}%
119 }
120 \define@key{igraph}{bb}{}
121 \define@key{igraph}{bbllx}{}
122 \define@key{igraph}{bblly}{}
123 \define@key{igraph}{bburx}{}
124 \define@key{igraph}{bbury}{}
125 \define@key{igraph}{natwidth}{}
126 \define@key{igraph}{natheight}{}
127 \define@key{igraph}{hiresbb}[true]{}
128 \define@key{igraph}{viewport}{}
129 \define@key{igraph}{trim}{}
130 \define@key{igraph}{totalheight}{}
131 \define@key{igraph}{clip}[true]{}
132 \define@key{igraph}{draft}[true]{}
133 \define@key{igraph}{type}{}
134 \define@key{igraph}{ext}{}
135 \define@key{igraph}{read}{}
136 \define@key{igraph}{command}{}
137 \define@key{igraph}{quite}{}
138 \define@key{igraph}{page}{}
139 \define@key{igraph}{pagebox}{}
140 \define@key{igraph}{interpolate}[true]{}
141 \define@key{igraph}{decodearray}{}
142
143
144 \newcommand*{\LWR@rotstyle}[2]{%
145 \edef\LWR@tempone{#2}%
146 \setcounter{LWR@tempcountone}{-1*\real{\LWR@tempone}} % space
147 #1transform:rotate(\arabic{LWR@tempcountone}deg); % space
148 }
149
150 \newcommand*{\LWR@scalestyle}[3]{%
151 #1transform:scale(#2,#3);
152 }
153
154
155 \def\LWR@opacity{1}
156
157 \newsavebox{\LWR@imagesizebox}
158
159 \newcommand*{\LWR@HTML@Gin@setfile}[3]{%
160 \xdef\LWR@parsedfilename{#3}%
161 }
162
163 \AtBeginDocument{
164 \define@key{Gin}{class}{}
165 }
166
167 \AtBeginDocument{
168 \IfPackageLoadedTF{epstopdf}
169 {
170 \newcommand*{\LWR@replaceEPSSVG}{}
171 }{%
172 \newcommand*{\LWR@replaceEPSSVG}{%
173 \StrSubstitute{\LWR@tempone}{.eps}{.svg}[\LWR@tempone]%
174 \StrSubstitute{\LWR@tempone}{.EPS}{.SVG}[\LWR@tempone]%
175 }
176 }%
177 }
178
179 \newcommand*{\LWR@ig@useactualimagesize}[4]{%
180 \begingroup%
181 \LWR@restoreorigformatting%
182 \ifpdf%
183 \appto\LWR@restoreorigformatting{%
184 \DeclareGraphicsExtensions{%
185 .pdf,.PDF,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG%
186 }%
187 }%
188 \else% \ifpdf
189 \ifXeTeX%
190 \appto\LWR@restoreorigformatting{%
191 \DeclareGraphicsExtensions{%
192 .pdf,.PDF,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG%
193 }%
194 }%
195 \else%
196 \appto\LWR@restoreorigformatting{%
197 \DeclareGraphicsExtensions{%
198 .eps,.EPS,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG%
199 }%
200 }%
201 \fi%
202 \fi% \ifpdf
203 \ifbool{FormatWP}{\define@key{Gin}{angle}{}}{}%
204 \IfBooleanTF{#1}%
205 {% starred
206 \IfValueTF{#3}%
207 {%
208 \global\sbox{\LWR@imagesizebox}{%
209 \LWR@origincludegraphics*[#2][#3]{#4}%
210 }%
211 }%
212 {%
213 \IfValueTF{#2}%
214 {%
215 \global\sbox{\LWR@imagesizebox}{%
216 \LWR@origincludegraphics*[#2]{#4}%
217 }%
218 }{%
219 \global\sbox{\LWR@imagesizebox}{%
220 \LWR@origincludegraphics*{#4}%
221 }%
222 }%
223 }%
224 }% starred
225 {% not starred
226 \IfValueTF{#3}%
227 {%
228 \global\sbox{\LWR@imagesizebox}{%
229 \LWR@origincludegraphics[#2][#3]{#4}%
230 }%
231 }%
232 {%
233 \IfValueTF{#2}%
234 {%
235 \global\sbox{\LWR@imagesizebox}{%
236 \LWR@origincludegraphics[#2]{#4}%
237 }%
238 }{%
239 \global\sbox{\LWR@imagesizebox}{%
240 \LWR@origincludegraphics{#4}%
241 }%
242 }%
243 }%
244 }% not starred
245 \endgroup%
246 \settowidth{\LWR@igwidth}{\usebox{\LWR@imagesizebox}}%
247 \global\renewcommand*{\LWR@igwidthstyle}{%
248 width:\LWR@printlength{\LWR@igwidth}%
249 }%
250 \settoheight{\LWR@igheight}{\usebox{\LWR@imagesizebox}}%
251 \global\renewcommand*{\LWR@igheightstyle}{%
252 height:\LWR@printlength{\LWR@igheight}%
253 }%
254 }
255
256 \newcommand*{\LWR@ig@htmltag}{%
257 img\LWR@indentHTML%
258 src=\textquotedbl%
259 \detokenize\expandafter{\LWR@parsedfilename}%
260 \textquotedbl\LWR@indentHTML%
261 \ifthenelse{
262 \NOT\equal{\LWR@igwidthstyle}{} \OR
263 \NOT\equal{\LWR@igheightstyle}{} \OR
264 \NOT\equal{\LWR@igorigin}{} \OR
265 \NOT\equal{\LWR@igangle}{} \OR
266 \NOT\equal{\LWR@igxscale}{1} \OR
267 \NOT\equal{\LWR@igyscale}{1}
268 }%
269 {%
270 style=\textquotedbl\LWR@indentHTML
271 \ifthenelse{\NOT\equal{\LWR@igwidthstyle}{}}%
272 {\LWR@igwidthstyle;\LWR@indentHTML}{}%
273 \ifthenelse{\NOT\equal{\LWR@igheightstyle}{}}%
274 {\LWR@igheightstyle;\LWR@indentHTML}{}%
275 \ifthenelse{\NOT\equal{\LWR@igorigin}{}}%
276 {%
277 transform-origin: \LWR@originnames{\LWR@igorigin};%
278 \LWR@indentHTML%
279 }{}%
280 \ifthenelse{\NOT\equal{\LWR@igangle}{}}%
281 {%
282 \LWR@rotstyle{-ms-}{\LWR@igangle}\LWR@indentHTML
283 \LWR@rotstyle{-webkit-}{\LWR@igangle}\LWR@indentHTML
284 \LWR@rotstyle{}{\LWR@igangle }\LWR@indentHTML
285 }{}%
286 \ifthenelse{%
287 \NOT\equal{\LWR@igxscale}{1}\OR%
288 \NOT\equal{\LWR@igyscale}{1}%
289 }%
290 {%
291 \LWR@scalestyle{-ms-}{\LWR@igxscale}{\LWR@igyscale}%
292 \LWR@indentHTML
293 \LWR@scalestyle{-webkit-}{\LWR@igxscale}{\LWR@igyscale}%
294 \LWR@indentHTML
295 \LWR@scalestyle{}{\LWR@igxscale}{\LWR@igyscale}%
296 \LWR@indentHTML
297 }{}%
298 %
299 \ifthenelse{\NOT\equal{\LWR@opacity}{1}}%
300 {opacity:\LWR@opacity;\LWR@indentHTML}{}%
301 %
302 \textquotedbl\LWR@indentHTML%
303 }{}%
304 class=\textquotedbl\LWR@igclass\textquotedbl\LWR@indentHTML%
305 \ifdefempty{\LWR@ThisAltText}%
306 {}%
307 {%
308 alt=\textquotedbl%
309 \AltTextOpen\LWR@ThisAltText\AltTextClose%
310 \textquotedbl%
311 \gdef\LWR@ThisAltText{}%
312 }%
313 \ \LWR@orignewline%
314 }% end of image tags
315
316 \NewDocumentCommand{\LWR@includegraphicsb}{s o o m}
317 {%
318 \LWR@orignobreakspace \LWR@orignewline%
319 \begin{LWR@setvirtualpage}%
320 \large%
321 \hbadness=10000\relax%
322 \setlength{\LWR@igwidth}{0pt}%
323 \setlength{\LWR@igheight}{0pt}%
324 \renewcommand*{\LWR@igwidthstyle}{}%
325 \renewcommand*{\LWR@igheightstyle}{}%
326 \renewcommand*{\LWR@igorigin}{}%
327 \renewcommand*{\LWR@igangle}{}%
328 \renewcommand*{\LWR@igxscale}{1}%
329 \renewcommand*{\LWR@igyscale}{1}%
330 \renewcommand*{\LWR@igclass}{inlineimage}%
331 \boolfalse{LWR@igkeepaspectratio}%
332 \IfValueF{#3}{%
333 \IfValueTF{#2}%
334 {\setkeys{igraph}{#2}}%
335 {\setkeys{igraph}{}}%
336 }%
337 \begingroup%
338 \LetLtxMacro\Gin@setfile\LWR@HTML@Gin@setfile%
339 \edef\LWR@tempone{#4}%
340 \StrSubstitute{\LWR@tempone}{.pdf}{}[\LWR@tempone]%
341 \StrSubstitute{\LWR@tempone}{.PDF}{}[\LWR@tempone]%
342 \LWR@replaceEPSSVG%
343 \xdef\LWR@parsedfilename{\LWR@tempone}%
344 \Ginclude@graphics{\detokenize\expandafter{\LWR@parsedfilename}}%
345 \endgroup%
346 \filename@parse{\LWR@parsedfilename}%
347 \StrSubstitute{\LWR@parsedfilename}{//}{/}[\LWR@parsedfilename]%
348 \LWR@traceinfo{LWR@parsedfilename is \LWR@parsedfilename}%
349 \ifboolexpr{
350 bool {FormatWP} or
351 bool {LWR@igkeepaspectratio}
352 }{\LWR@ig@useactualimagesize{#1}{#2}{#3}{#4}}{}%
353 \LWR@traceinfo{LWR@includegraphicsb: about to create href}%
354 \boolfalse{LWR@HTMLsanitize@tmpb@removebackslash}%
355 \edef\LWR@prev@ThisAltText{\LWR@ThisAltText}%
356 \LWR@href@partsanitized{\LWR@parsedfilename}%
357 {% start of href
358 \LWR@traceinfo{LWR@includegraphicsb: about to LWR@htmltag}%
359 \edef\LWR@ThisAltText{\LWR@prev@ThisAltText}%
360 \ifdefvoid{\LWR@ThisAltText}{\edef\LWR@ThisAltText{\ImageAltText}}{}%
361 \LWR@htmltag{\LWR@ig@htmltag}%
362 }% end of href
363 \end{LWR@setvirtualpage}%
364 \gdef\LWR@ThisAltText{}%
365 \LWR@traceinfo{LWR@includegraphicsb done}%
366 }
367
368
369
370
371 \AtBeginDocument{
372
373 \LWR@traceinfo{Patching includegraphics.}
374
375 \LetLtxMacro\LWR@origincludegraphics\includegraphics
376
377 \renewrobustcmd*{\includegraphics}
378 {%
379 \LWR@traceinfo{includegraphics}%
380 \LWR@ensuredoingapar%
381 \LWR@includegraphicsb%
382 }% includegraphics
383 }% AtBeginDocument
384
385
386 \newcommand*{\LWR@rotboxorigin}{}
387 \newcommand*{\LWR@originname}[1]{%
388 \ifthenelse{\equal{#1}{t}}{top}{}%
389 \ifthenelse{\equal{#1}{b}}{bottom}{}%
390 \ifthenelse{\equal{#1}{c}}{center}{}%
391 \ifthenelse{\equal{#1}{l}}{left}{}%
392 \ifthenelse{\equal{#1}{r}}{right}{}%
393 }
394 \newcommand*{\LWR@originnames}[1]{%
395 \StrChar{#1}{1}[\LWR@strresult]%
396 \LWR@originname{\LWR@strresult}
397 \StrChar{#1}{2}[\LWR@strresult]%
398 \LWR@originname{\LWR@strresult}
399 }
400 \define@key{krotbox}{origin}{%
401 \renewcommand*{\LWR@rotboxorigin}{#1}%
402 }
403 \define@key{krotbox}{x}{}
404 \define@key{krotbox}{y}{}
405 \define@key{krotbox}{units}{}
406 \AtBeginDocument{
407 \NewDocumentCommand{\LWR@HTML@rotatebox}{O{} m +m}{%
408 \renewcommand*{\LWR@rotboxorigin}{}
409 \setkeys{krotbox}{#1}%
410 \LWR@htmltagc{%
411 span\LWR@indentHTML
412 style=\textquotedbl\LWR@indentHTML
413 display: inline-block;\LWR@indentHTML
414 \ifthenelse{\NOT\equal{\LWR@rotboxorigin}{}}%
415 {transform-origin: \LWR@originnames{\LWR@rotboxorigin};\LWR@indentHTML}%
416 {}%
417 \LWR@rotstyle{-ms-}{#2}\LWR@indentHTML
418 \LWR@rotstyle{-webkit-}{#2}\LWR@indentHTML
419 \LWR@rotstyle{}{#2}\textquotedbl\LWR@orignewline%
420 }\LWR@orignewline%
421 \begin{LWR@nestspan}%
422 #3%
423 \LWR@htmltagc{/span}%
424 \end{LWR@nestspan}%
425 }
426 \LWR@formatted{rotatebox}
427
428 }% AtBeginDocument
429
430 \AtBeginDocument{
431 \NewDocumentCommand{\LWR@HTML@scalebox}{m o m}{%
432 \LWR@htmltagc{%
433 span\LWR@indentHTML
434 style=\textquotedbl\LWR@indentHTML
435 display: inline-block;\LWR@indentHTML
436 \LWR@scalestyle{-ms-}{#1}{\IfNoValueTF{#2}{#1}{#2}}\LWR@indentHTML
437 \LWR@scalestyle{-webkit-}{#1}{\IfNoValueTF{#2}{#1}{#2}}\LWR@indentHTML
438 \LWR@scalestyle{}{#1}{\IfNoValueTF{#2}{#1}{#2}}
439 \textquotedbl\LWR@orignewline
440 }\LWR@orignewline%
441 \begin{LWR@nestspan}%
442 #3%
443 \LWR@htmltagc{/span}%
444 \end{LWR@nestspan}%
445 }
446 \LWR@formatted{scalebox}
447
448 }% AtBeginDocument
449
450 \AtBeginDocument{
451
452 \newcommand{\LWR@HTML@reflectbox}[1]{%
453 \scalebox{-1}[1]{#1}%
454 }% \reflectbox
455
456 \LWR@formatted{reflectbox}
457
458 }% AtBeginDocument
459
460 \AtBeginDocument{
461
462 \NewDocumentCommand{\LWR@HTML@resizebox}{s m m m}{%
463 #4%
464 }
465
466 \LWR@formatted{resizebox}
467
468 }% AtBeginDocument
469
470 \endinput
471 %%
472 %% End of file `lwarp-graphics.sty'.