Debian Codegraph @

texmf-dist/source/support/latex-make/figlatex.dtx

raw
1 % \iffalse meta-comment
2 %%
3 %% File: figlatex.dtx Copyright (C) 2002--2005 V. Danjean, A. Legrand
4 %% [email protected]
5 %% [email protected]
6 %%
7 %% This program is free software; you can redistribute it and/or
8 %% modify it under the terms of the GNU General Public License
9 %% as published by the Free Software Foundation; either version 2
10 %% of the License, or (at your option) any later version.
11 %%
12 %% This program is distributed in the hope that it will be useful,
13 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
14 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 %% GNU General Public License for more details.
16 %%
17 %% You should have received a copy of the GNU General Public License
18 %% along with this program; if not, write to the Free Software
19 %% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 %%
21 %
22 %<*dtx>
23 \ProvidesFile{figlatex.dtx}
24 %</dtx>
25 %<package>\NeedsTeXFormat{LaTeX2e}%
26 %<package>\ProvidesPackage{figlatex}%
27 %<config> \ProvidesFile{figlatex.cfg}%
28 %<compat> \ProvidesPackage{texgraphicx}%
29 % \fi
30 % \ProvidesFile{figlatex.dtx}
31 [2021/10/26 v2.4.3 No changes in figlatex]
32 % \iffalse
33 %<*driver>
34 \documentclass{ltxdoc}
35 \usepackage[latin1]{inputenc}
36 \usepackage[french,english]{babel}
37 \NoAutoSpaceBeforeFDP
38 \EnableCrossrefs
39 \CodelineIndex
40 \RecordChanges
41 \setcounter{IndexColumns}{2} % make a twocolumn index
42 \setlength{\columnseprule}{0pt} % no rules between columns ...
43 \setlength{\columnsep}{2em} % ... but more spacing instead.
44 \setcounter{unbalance}{4}
45 \setlength{\IndexMin}{100pt}
46 %%%%\OnlyDescription % uncomment this line to suppress printing the source code
47 \makeatletter
48 % don't show underfull hboxes in index/glossary:
49 \g@addto@macro{\IndexParms}{\hbadness=10000}
50 \g@addto@macro{\GlossaryParms}{\hbadness=10000}
51 \makeatother
52 \begin{document}
53 \DocInput{figlatex.dtx}
54 \PrintIndex
55 \PrintChanges
56 \end{document}
57 %</driver>
58 % \fi
59 %
60 % \GetFileInfo{figlatex.dtx}
61 %
62 % \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ }
63 % \DoNotIndex{\def,\long,\edef,\xdef,\gdef,\let,\global}
64 % \DoNotIndex{\if,\ifnum,\ifdim,\ifcat,\ifmmode,\ifvmode,\ifhmode,%
65 % \iftrue,\iffalse,\ifvoid,\ifx,\ifeof,\ifcase,\else,\or,\fi,\loop,\do}
66 % \DoNotIndex{\box,\copy,\setbox,\unvbox,\unhbox,\hbox,%
67 % \vbox,\vtop,\vcenter}
68 % \DoNotIndex{\@empty,\immediate,\write}
69 % \DoNotIndex{\egroup,\bgroup,\expandafter,\begingroup,\endgroup}
70 % \DoNotIndex{\divide,\advance,\multiply,\count,\dimen}
71 % \DoNotIndex{\relax,\space,\string}
72 % \DoNotIndex{\csname,\endcsname,\@spaces,\openin,\openout,%
73 % \closein,\closeout}
74 % \DoNotIndex{\catcode,\endinput}
75 % \DoNotIndex{\jobname,\message,\read,\the,\noexpand}
76 % \DoNotIndex{\hsize,\vsize,\hskip,\vskip,\kern,\hfil,\hfill,\hss}
77 % \DoNotIndex{\m@ne,\z@,\@m,\z@skip,\@ne,\tw@,\p@}
78 % \DoNotIndex{\DeclareRobustCommand,\DeclareOption,\newcommand,\newcommand*}
79 % \DoNotIndex{\newcount,\newif,\newlinechar,\newread,\newtoks,\newwrite}
80 % \DoNotIndex{\dp,\wd,\ht,\vss,\unskip,\ifthenelse}
81 %
82 % \DoNotIndex{\@filef@und,\@nameddef,\@tempa}
83 % \DoNotIndex{\define@key,\equal,\ExecuteOptions}
84 % \DoNotIndex{\filename@area,\filename@base,\filename@ext,\filename@parse}
85 % \DoNotIndex{\Gin@exclamation,\Gin@getbase,\Gin@scalex,\Gin@scaley}
86 % \DoNotIndex{\Gread@eps,\Gread@pdf,\Gscale@box}
87 % \DoNotIndex{\IfFileExists,\ifpdf,\input,\InputIfFileExists}
88 % \DoNotIndex{\MessageBreak,\PackageWarning,\PackageWarningNoLine}
89 % \DoNotIndex{\ProcessOptions,\RequirePackage,\typeout}
90 % \DoNotIndex{}
91 % \DoNotIndex{}
92 %
93 % \title{The \textsf{figlatex} package\thanks{This file
94 % has version number \fileversion, last
95 % revised \filedate.}}
96 % \author{Arnaud \textsc{Legrand}\and Vincent \textsc{Danjean}}
97 % \date{\filedate}
98 % \maketitle
99 % \begin{abstract}
100 % This package allows \LaTeX\space to load XFig and SVG figures (or
101 % subfigures) with the |\includegraphics| command.
102 % \end{abstract}
103 % \CheckSum{207}
104 %
105 % \changes{v0.1.1}{2005/03/28}{Version 0.1.1 at last}
106 % \changes{v0.1.2}{2005/03/29}{Manage index/glossary}
107 % \changes{v0.1.3}{2008/01/28}{Better support for subfig with texdepends}
108 % \changes{v0.1.4}{2011/09/25}{Support for svg with texdepends}
109 % \changes{v2.2.0}{2016/02/09}{No changes in figlatex.dtx}
110 % \changes{v2.2.1}{2016/02/09}{No changes in figlatex.dtx}
111 % \changes{v2.2.2}{2016/02/09}{No changes in figlatex.dtx}
112 % \changes{v2.2.3}{2017/01/08}{No changes in figlatex.dtx}
113 % \changes{v2.2.4}{2018/05/29}{Add missing required package 'ifthen'}
114 % \changes{v2.2.4}{2018/05/29}{Fix python syntax for python3}
115 % \changes{v2.2.5}{2018/09/04}{No changes in figlatex.dtx}
116 % \changes{v2.2.5}{2018/10/17}{No changes in figlatex.dtx}
117 % \changes{v2.4.0}{2020/06/01}{Fix path handling for subfig and new
118 % core LaTeX}
119 % \changes{v2.4.1}{2020/07/10}{No changes in figlatex.dtx}
120 % \changes{v2.4.2}{2021/01/03}{No changes in figlatex.dtx}
121 % \changes{v2.4.3}{2021/04/18}{No changes in figlatex.dtx}
122 %
123 % \makeatletter
124 % \def\SpecialOptionIndex#1{\@bsphack
125 % \index{#1\actualchar{\protect\ttfamily#1}
126 % (option)\encapchar usage}%
127 % \index{options:\levelchar{\protect\ttfamily#1}\encapchar
128 % usage}\@esphack}
129 % \def\SpecialFileIndex#1{\@bsphack
130 % \index{#1\actualchar{\protect\ttfamily#1}
131 % (file)\encapchar usage}%
132 % \index{files:\levelchar{\protect\ttfamily#1}\encapchar
133 % usage}\@esphack}
134 % \def\SpecialMainOptionIndex#1{\@bsphack\special@index{#1\actualchar
135 % {\string\ttfamily\space#1}
136 % (option)\encapchar main}%
137 % \special@index{options:\levelchar{%
138 % \string\ttfamily\space#1}\encapchar
139 % main}\@esphack}
140 % \def\option{\begingroup
141 % \catcode`\\12
142 % \MakePrivateLetters \mym@cro@ \iffalse}
143 % \long\def\mym@cro@#1#2{\endgroup \topsep\MacroTopsep \trivlist
144 % \edef\saved@macroname{\string#2}%
145 % \def\makelabel##1{\llap{##1}}%
146 % \if@inlabel
147 % \let\@tempa\@empty \count@\macro@cnt
148 % \loop \ifnum\count@>\z@
149 % \edef\@tempa{\@tempa\hbox{\strut}}\advance\count@\m@ne \repeat
150 % \edef\makelabel##1{\llap{\vtop to\baselineskip
151 % {\@tempa\hbox{##1}\vss}}}%
152 % \advance \macro@cnt \@ne
153 % \else \macro@cnt\@ne \fi
154 % \edef\@tempa{\noexpand\item[%
155 % #1%
156 % \noexpand\PrintMacroName
157 % \else
158 % \noexpand\PrintEnvName
159 % \fi
160 % {\string#2}]}%
161 % \@tempa
162 % \global\advance\c@CodelineNo\@ne
163 % #1%
164 % \SpecialMainIndex{#2}\nobreak
165 % \DoNotIndex{#2}%
166 % \else
167 % \SpecialMainOptionIndex{#2}\nobreak
168 % \fi
169 % \global\advance\c@CodelineNo\m@ne
170 % \ignorespaces}
171 % \let\endoption \endtrivlist
172 % \def\DescribeOption{\leavevmode\@bsphack\begingroup\MakePrivateLetters
173 % \Describe@Option}
174 % \def\Describe@Option#1{\endgroup
175 % \marginpar{\raggedleft\PrintDescribeEnv{#1}}%
176 % \SpecialOptionIndex{#1}\@esphack\ignorespaces}
177 % \def\DescribeFile{\leavevmode\@bsphack\begingroup\MakePrivateLetters
178 % \Describe@Option}
179 % \def\Describe@File#1{\endgroup
180 % \marginpar{\raggedleft\PrintDescribeEnv{#1}}%
181 % \SpecialFileIndex{#1}\@esphack\ignorespaces}
182 % \makeatother
183 % \MakeShortVerb{\|}
184 %
185 % \section{Introduction}
186 %
187 % \subsection{General}
188 % \DescribeMacro{\includegraphics}
189 % This package allows to load XFig figures from \LaTeX\space sources with
190 % the |\includegraphics| command from the |graphicx| package:
191 % \begin{verbatim}
192 % \includegraphics[width=\linewidth]{myfig.fig}
193 % \end{verbatim}
194 %
195 % This package does not convert by itself XFig figures (see package
196 % |texdepends| for that). It only diverts the loading functions so
197 % that \LaTeX\space includes the |.pstex_t| or the |.pdftex_t|.
198 %
199 % \subsection{Options}
200 % Available options for this package:
201 % \begin{description}
202 % \item[debug~:] \DescribeOption{debug}more messages written while compiling
203 % \end{description}
204 %
205 % \DescribeFile{figlatex.cfg}
206 % \DescribeMacro{\debug}
207 % When the package is loaded, it tries to read a |figlatex.cfg|
208 % file. This file can contains |\debug| to
209 % enable this option site wide.
210 %
211 % \subsection{Subfigures}
212 %
213 % Sometimes, several figures made with XFig should be similar. It is
214 % possible to make only one XFig figure and then create subfigures
215 % which contains only a subset of the depths of the original figure.
216 %
217 % \StopEventually{
218 % }
219 % \section{Implementation}
220 %
221 % \subsection{figlatex}
222 % \begin{macrocode}
223 %<*package>
224 % \end{macrocode}
225 %
226 % Options definitions
227 % \begin{option}{debug}
228 % \begin{macrocode}
229 \newif\ifFL@debug
230 \DeclareOption{debug}{%
231 \global\FL@debugtrue%
232 }
233 % \end{macrocode}
234 % \end{option}
235 %
236 % We load the config file if it exists.
237 % Commands for the config file are local.
238 % \begin{macrocode}
239 {
240 % \end{macrocode}
241 % \begin{macro}{\debug}
242 % \begin{macrocode}
243 \def\debug{%
244 \ExecuteOptions{debug}%
245 }
246 % \end{macrocode}
247 % \end{macro}
248 % \begin{macrocode}
249 \InputIfFileExists{figlatex.cfg}{%
250 \typeout{***************************************^^J%
251 * Local config file figlatex.cfg used *^^J%
252 ***************************************}
253 }{%
254 \typeout{Found no configuration file for figlatex}
255 }
256 }
257 % \end{macrocode}
258 % Run the options
259 % \begin{macrocode}
260 \ProcessOptions
261 % \end{macrocode}
262 % and requires some packages
263 % \begin{macrocode}
264 \RequirePackage{ifthen}
265 \RequirePackage{ifpdf}
266 \RequirePackage{graphicx}
267 \RequirePackage{xstring}
268 % \end{macrocode}
269 % XFig uses heavily the color package
270 % \begin{macrocode}
271 \RequirePackage{color}
272 \RequirePackage{epstopdf}
273 % \end{macrocode}
274 % \begin{macro}{\FL@dmessage}
275 % Write the message only if debug is set
276 % \begin{macrocode}
277 \def\FL@dmessage#1{%
278 \ifFL@debug%
279 \message{#1}%
280 \fi%
281 }
282 % \end{macrocode}
283 % \end{macro}
284 % \begin{macro}{\Ginclude@rawtex}
285 % |.pstex_t| or |.pdftex_t| are loaded with |\input|
286 % \begin{macrocode}
287 \def\Ginclude@rawtex#1{%
288 \FL@dmessage{<#1>}%
289 \bgroup%
290 \def\@tempa{!}%
291 \ifx\Gin@scaley\@tempa%
292 \let\Gin@scaley\Gin@scalex%
293 \else%
294 \ifx\Gin@scalex\@tempa\let\Gin@scalex\Gin@scaley\fi%
295 \fi%
296 \hbox{%
297 \Gscale@box{\Gin@scalex}[\Gin@scaley]{%
298 \def\Gin@scalex{1}%
299 \let\Gin@scaley\Gin@exclamation% needed for pdflatex
300 \FL@dmessage{<loading rawtex #1>}%
301 \input{#1}}}%
302 \egroup}
303 % \end{macrocode}
304 % \end{macro}
305 % \begin{macro}{\Ginclude@figtex}
306 % |.fig| are loaded with |\includegraphics| after modifying the name
307 % \begin{macrocode}
308 \def\Ginclude@figtex#1{%
309 \message{<#1>}%
310 \bgroup%
311 \xdef\FL@filename{#1}%
312 \filename@parse{\FL@filename}%
313 \xdef\FL@filename{\filename@area\filename@base.\FL@figext}%
314 \FL@dmessage{<****loading fig \FL@filename>}%
315 \FL@includerawtexgraphics[]{\FL@filename}%
316 \egroup}
317 % \end{macrocode}
318 % \end{macro}
319 % \begin{macro}{\Gread@figtex}
320 % |.fig| bounding box is the same as the corresponding |.pstex_t| or |.pdftex_t|
321 % \begin{macrocode}
322 \newcommand{\Gread@figtex}[1]{%
323 %\typeout{Oh, file exists #1}%
324 \Gread@rawtex{#1}%
325 }
326 % \end{macrocode}
327 % \end{macro}
328 % \begin{macro}{\Ginclude@svgtex}
329 % |.svg| are loaded with |\includegraphics| after modifying the name
330 % \begin{macrocode}
331 \def\Ginclude@svgtex#1{%
332 \message{<#1>}%
333 \bgroup%
334 \xdef\FL@filename{#1}%
335 \filename@parse{\FL@filename}%
336 \xdef\FL@filename{\filename@area\filename@base.\FL@svgext}%
337 \FL@dmessage{<****loading svg \FL@filename>}%
338 \FL@includerawtexgraphics[]{\FL@filename}%
339 \egroup}
340 % \end{macrocode}
341 % \end{macro}
342 % \begin{macro}{\Gread@svgtex}
343 % |.svg| bounding box is the same as the corresponding |.pstex_t| or |.pdftex_t|
344 % \begin{macrocode}
345 \newcommand{\Gread@svgtex}[1]{%
346 %\typeout{Oh, file exists #1}%
347 \Gread@rawtex{#1}%
348 }
349 % \end{macrocode}
350 % \end{macro}
351 % Declare the right things depending whether we build a DVI or a PDF file.
352 % \begin{macrocode}
353 \ifpdf
354 % \end{macrocode}
355 % PDF part
356 % \begin{macrocode}
357 \def\FL@figext{pdftex_t}%
358 \def\FL@svgext{pdftex_t}%
359 % \end{macrocode}
360 % To read bounding box information:
361 % \begin{macrocode}
362 \let\Gread@rawtex\Gread@pdf%
363 \DeclareGraphicsRule{.pdftex}{pdf}{*}{}%
364 \DeclareGraphicsRule{.pdftex_t}{rawtex}{.pdftex}{}%
365 \DeclareGraphicsRule{.fig}{figtex}{.pdftex}{}%
366 \DeclareGraphicsRule{.svg}{svgtex}{.pdftex}{}%
367 \else
368 % \end{macrocode}
369 % DVI part
370 % \begin{macrocode}
371 \def\FL@figext{pstex_t}%
372 \def\FL@svgext{pstex_t}%
373 % \end{macrocode}
374 % To read bounding box information:
375 % \begin{macrocode}
376 \let\Gread@rawtex\Gread@eps%
377 \DeclareGraphicsRule{.pstex}{eps}{*}{}%
378 \DeclareGraphicsRule{.pstex_t}{rawtex}{.pstex}{}%
379 \DeclareGraphicsRule{.fig}{figtex}{.pstex}{}%
380 \DeclareGraphicsRule{.svg}{svgtex}{.pstex}{}%
381 \fi
382 % \end{macrocode}
383 % This command is not really necessary here (code could be added in
384 % |\Ginclude@figtex|). However, it's very convinient for the
385 % |texdepends| package.
386 % \begin{macrocode}
387 \newcommand{\FL@includerawtexgraphics}[2][]{%
388 \includegraphics[#1]{#2}%
389 }
390 % \end{macrocode}
391 % Addition of the |subfig=name| key for the options of the
392 % |\includegraphicx[..]{..}| macro.
393 % \begin{macrocode}
394 \def\FL@exclamation{!}%
395 \let\FL@subfig@name\FL@exclamation%
396 \define@key{Gin}{subfig}{%
397 \typeout{using subfig #1}%
398 \def\FL@subfig@name{#1}%
399 }
400 \def\FL@sepdefault{_}%
401 % \end{macrocode}
402 % We should ckeck if the \#1 file exists (XXX.subfig)
403 % This is not yet done but texdepends divert this macro
404 % to record the dependency
405 % \begin{macrocode}
406 \def\FL@subfig@check#1{%
407 }
408 % \end{macrocode}
409 % We divert |\Gin@getbase| to modify the file name if the |subfig| key
410 % is used.
411 % \begin{macrocode}
412 \def\FL@Gin@getbase#1{%
413 \typeout{In getbase #1 with \FL@subfig@name / \FL@exclamation}%
414 \ifx\FL@subfig@name\FL@exclamation%
415 \else%
416 \typeout{getbase lets go (\filename@area)(\filename@base)(#1)}%
417 \IfStrEq*{#1}{.fig}{%
418 % If we're including a subfig
419 \IfFileExists{\filename@area\filename@base#1}{%
420 % If the original .fig file exists, just change the name so that
421 % it comprises the full path (file has been looked into
422 % texgraphics, etc.)
423 % Warning: the found filename is quoted :-(
424 \StrBetween[1,2]{\@filef@und}{"}{"}[\FL@filename@unquoted]
425 \filename@parse{\FL@filename@unquoted}%
426 % Check if the subfig file exists
427 \FL@subfig@check{\filename@area\[email protected]}%
428 }{%
429 % Else, write a warning (LaTeX will warn as well but it doesn't
430 % hurt)
431 \PackageWarning{figlatex}{No file
432 '\filename@area\filename@base#1'}%
433 }
434 % Add the subfig suffix to the fig name.
435 \edef\filename@base{\filename@base\FL@sepdefault\FL@subfig@name}%
436 }{%
437 }%
438 \IfStrEq*{#1}{.svg}{%
439 % If we're including a subfig
440 \IfFileExists{\filename@area\filename@base#1}{%
441 % If the original .svg file exists, just change the name so that
442 % it comprises the full path (file has been looked into
443 % texgraphics, etc.)
444 % Warning: the found filename is quoted :-(
445 \StrBetween[1,2]{\@filef@und}{"}{"}[\FL@filename@unquoted]
446 \filename@parse{\FL@filename@unquoted}%
447 % Check if the subfig file exists
448 \FL@subfig@check{\filename@area\[email protected]}%
449 }{%
450 % Else, write a warning (LaTeX will warn as well but it doesn't
451 % hurt)
452 \PackageWarning{figlatex}{No file
453 '\filename@area\filename@base#1'}%
454 }
455 % Add the subfig suffix to the svg name.
456 \edef\filename@base{\filename@base\FL@sepdefault\FL@subfig@name}%
457 }{%
458 }%
459 \fi%
460 \FL@orig@Gin@getbase{#1}%
461 }
462 \let\FL@orig@Gin@getbase\Gin@getbase
463 \let\Gin@getbase\FL@Gin@getbase
464
465 %\@namedef{Gin@[email protected]}#1{%
466
467 %}
468 % \end{macrocode}
469 % \begin{macrocode}
470 %</package>
471 % \end{macrocode}
472 % The sample config file |figlatex.cfg|\ldots
473 % \begin{macrocode}
474 %<*config>
475 % \end{macrocode}
476 % \begin{macrocode}
477 %\debug
478 % \end{macrocode}
479 % \begin{macrocode}
480 %</config>
481 % \end{macrocode}
482 % \subsection{texgraphicx}
483 % \begin{macrocode}
484 %<*compat>
485 % \end{macrocode}
486 % |texgraphicx.sty| was only a wrapper arround |figlatex.sty|. Now, an
487 % error is generated.
488 % \begin{macrocode}
489 \PackageError{texgraphicx}{'texgraphicx' is now
490 gone\MessageBreak%
491 Please, switching to 'figlatex'
492 package\MessageBreak}{}
493 \ProcessOptions
494 % \end{macrocode}
495 % \begin{macrocode}
496 %</compat>
497 % \end{macrocode}
498 % \Finale
499 \endinput