Debian Codegraph @

texmf-dist/tex/latex/caption/caption2.sty

raw
1 %%
2 %% This is file `caption2.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% caption2.dtx (with options: `package')
8 %%
9 %% Copyright (C) 1994-2022 Axel Sommerfeldt ([email protected])
10 %%
11 %% https://gitlab.com/axelsommerfeldt/caption
12 %%
13 %% --------------------------------------------------------------------------
14 %%
15 %% This work may be distributed and/or modified under the
16 %% conditions of the LaTeX Project Public License, either version 1.3
17 %% of this license or (at your option) any later version.
18 %% The latest version of this license is in
19 %% http://www.latex-project.org/lppl.txt
20 %% and version 1.3 or later is part of all distributions of LaTeX
21 %% version 2003/12/01 or later.
22 %%
23 %% This work has the LPPL maintenance status "maintained".
24 %%
25 %% This Current Maintainer of this work is Axel Sommerfeldt.
26 %%
27 %% This work consists of the files
28 %% caption.ins, caption.dtx, caption-light.dtx, caption2.dtx, caption3.dtx,
29 %% caption-ams-smf.dtx, caption-beamer.dtx, caption-elsarticle.dtx,
30 %% caption-koma.dtx, caption-memoir.dtx, caption-ntg.dtx,
31 %% caption-thesis.dtx, bicaption.dtx, ltcaption.dtx, subcaption.dtx,
32 %% the derived files
33 %% caption.sty, caption-light.sty, caption2.sty, caption3.sty,
34 %% caption-ams-smf.sto, caption-beamer.sto, caption-elsarticle.sto,
35 %% caption-koma.sto, caption-memoir.sto, caption-ntg.sto,
36 %% caption-thesis.sto, bicaption.sty, ltcaption.sty, subcaption.sty.
37 %%
38 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
39 \providecommand\DeclareRelease[3]{}
40 \providecommand\DeclareCurrentRelease[2]{}
41 \DeclareRelease{v2.0}{1995-10-09}{caption2_1995-10-09.sty}
42 \DeclareRelease{v2.1}{2002-08-03}{caption2_2005-10-03.sty}
43 \DeclareCurrentRelease{v2.2}{2007-04-09} % 1st version using caption3
44 \ProvidesPackage{caption2}[2021/01/20 v2.2i Customising captions (AR)]
45 \RequirePackage{caption3}[2007/03/04]
46 \newcommand*\captiontwo@Error[2][]{%
47 \PackageError{caption2}{#2}{#1\caption@@eh{caption2}}}
48 \providecommand*\caption@@eh[1]{%
49 If you do not understand this error, please take a closer look\MessageBreak
50 at the documentation of the `#1' package, especially the\MessageBreak
51 section about errors.\MessageBreak\@ehc}
52 \@ifpackageloaded{caption}{%
53 \captiontwo@Error{%
54 You can't use both, the (current) caption *and*\MessageBreak
55 the (obsolete) caption2 package}%
56 \endinput
57 }{}
58 \newcommand*\captionlabeldelim{}
59 \newcommand*\captionlabelsep{}
60 \@ifundefined{captionwidth}
61 {\let\captionwidth\caption@width}
62 {}
63 \newcommand*\ifcaptionwidth{\ifdim\captionwidth>\z@}
64 \@ifundefined{captionindent}
65 {\let\captionindent\caption@indent}
66 {}
67 \def\ifcaptionlabel{%
68 \ifcaption@star
69 \@tempswafalse
70 \else
71 \@tempswatrue
72 \fi
73 \if@tempswa}
74 \def\captionlabeltrue{\caption@starfalse}
75 \def\captionlabelfalse{\caption@startrue}
76 \def\ifonelinecaptions{%
77 \caption@ifslc{\@tempswatrue}{\@tempswafalse}%
78 \if@tempswa}
79 \def\onelinecaptionstrue{\caption@setbool{slc}{1}}
80 \def\onelinecaptionsfalse{\caption@setbool{slc}{0}}
81 \newif\ifignoreLTcapwidth
82 \providecommand*\setcaptionmargin{%
83 \setlength\captionwidth\z@
84 \setlength\captionmargin}
85 \providecommand*\setcaptionwidth{%
86 \setlength\captionmargin\z@
87 \setlength\captionwidth}
88 \newcommand*\normalcaptionparams{%
89 \let\captionsize\@empty
90 \renewcommand*\captionfont{\captionsize}%
91 \let\captionlabelfont\@empty
92 \renewcommand*\captionlabeldelim{:}%
93 \renewcommand*\captionlabelsep{\space}%
94 \setcaptionmargin\z@
95 \setlength\captionindent\z@
96 \onelinecaptionstrue}
97 \newcommand*\defcaptionstyle[1]{%
98 \@namedef{caption@@#1}}
99 \newcommand*\newcaptionstyle[1]{%
100 \expandafter\ifx\csname caption@@#1\endcsname\relax
101 \expandafter\defcaptionstyle
102 \else
103 \captiontwo@Error{Caption style `#1' already defined}%
104 \expandafter\@gobbletwo
105 \fi
106 {#1}}
107 \newcommand*\renewcaptionstyle[1]{%
108 \expandafter\ifx\csname caption@@#1\endcsname\relax
109 \captiontwo@Error{Caption style `#1' undefined}%
110 \expandafter\@gobbletwo
111 \else
112 \expandafter\defcaptionstyle
113 \fi
114 {#1}}
115 \newcommand*\dummycaptionstyle[2]{%
116 \defcaptionstyle{#1}{%
117 \expandafter\ifx\csname caption@@\caption@style\expandafter\endcsname%
118 \csname caption@@#1\endcsname
119 \captiontwo@Error
120 [The caption style `#1' is only a dummy and does not really exists.%
121 \MessageBreak You have to redefine it (with \protect\renewcaptionstyle)
122 before you can select\MessageBreak it with \protect\captionstyle.\space]%
123 {You can't use the caption style `#1' directy}%
124 \else
125 #2\usecaptionstyle\caption@style
126 \fi}}
127 \newcommand*\captionstyle[1]{%
128 \expandafter\ifx\csname caption@@#1\endcsname\relax
129 \captiontwo@Error{Undefined caption style `#1'}%
130 \else
131 \def\caption@style{#1}%
132 \fi}
133 \newcaptionstyle{normal}{\caption@make{normal}}
134 \newcaptionstyle{center}{\caption@make{center}}
135 \newcaptionstyle{centerlast}{\caption@make{centerlast}}
136 \newcaptionstyle{flushleft}{\caption@make{flushleft}}
137 \newcaptionstyle{flushright}{\caption@make{flushright}}
138 \newcaptionstyle{hang}{\caption@make{hang}}
139 \newcaptionstyle{hang+center}{\caption@make{hang@center}}
140 \newcaptionstyle{hang+centerlast}{\caption@make{hang@centerlast}}
141 \newcaptionstyle{hang+flushleft}{\caption@make{hang@flushleft}}
142 \newcaptionstyle{indent}{\caption@make{indent}}
143 \newcommand*\caption@makecaption[1]{%
144 \usecaptionmargin
145 \ifcaptionlabel
146 \def\caption@label{%
147 {\captionlabelfont\captionlabel\captionlabeldelim}\captionlabelsep}%
148 \else
149 \let\caption@label\@empty
150 \fi
151 \captionfont
152 \onelinecaption
153 {\caption@label\captiontext}%
154 {\parbox[b]\captionlinewidth{\strut\@nameuse{caption@@@#1}\par}\par}}
155 \newcommand*\caption@@@normal{%
156 \caption@label\captiontext}
157 \newcommand*\caption@@@center{%
158 \centering\caption@label\captiontext}%
159 \newcommand*\caption@@@centerlast{%
160 \centerlast\caption@label\captiontext}
161 \newcommand*\caption@@@flushleft{%
162 \raggedright\caption@label\captiontext}%
163 \newcommand*\caption@@@flushright{%
164 \raggedleft\caption@label\captiontext}%
165 \newcommand*\caption@@@hang{%
166 \sbox\@tempboxa{\caption@label}%
167 \hangindent\wd\@tempboxa\noindent
168 \usebox\@tempboxa\caption@hangplus\captiontext}
169 \newcommand*\caption@hangplus{}
170 \newcommand*\caption@@@hang@center{%
171 \let\caption@hangplus\centering\caption@@@hang}
172 \newcommand*\caption@@@hang@centerlast{%
173 \let\caption@hangplus\centerlast\caption@@@hang}
174 \newcommand*\caption@@@hang@flushleft{%
175 \let\caption@hangplus\raggedright\caption@@@hang}
176 \newcommand*\caption@@@indent{%
177 \hangindent\captionindent\noindent
178 \caption@label\captiontext}
179 \DeclareOption{normal}{\captionstyle{normal}}
180 \DeclareOption{center}{\captionstyle{center}}
181 \DeclareOption{centerlast}{\captionstyle{centerlast}}
182 \DeclareOption{flushleft}{\captionstyle{flushleft}}
183 \DeclareOption{flushright}{\captionstyle{flushright}}
184 \DeclareOption{anne}{\ExecuteOptions{centerlast}}
185 \DeclareOption{hang}{\captionstyle{hang}}
186 \DeclareOption{hang+center}{\captionstyle{hang+center}}
187 \DeclareOption{hang+centerlast}{\captionstyle{hang+centerlast}}
188 \DeclareOption{hang+flushleft}{\captionstyle{hang+flushleft}}
189 \DeclareOption{isu}{\ExecuteOptions{hang}}
190 \DeclareOption{indent}{\captionstyle{indent}}
191 \DeclareOption{scriptsize}{\g@addto@macro\captionsize\scriptsize}
192 \DeclareOption{footnotesize}{\g@addto@macro\captionsize\footnotesize}
193 \DeclareOption{small}{\g@addto@macro\captionsize\small}
194 \DeclareOption{normalsize}{\g@addto@macro\captionsize\normalsize}
195 \DeclareOption{large}{\g@addto@macro\captionsize\large}
196 \DeclareOption{Large}{\g@addto@macro\captionsize\Large}
197 \DeclareOption{up}{\g@addto@macro\captionlabelfont\upshape}
198 \DeclareOption{it}{\g@addto@macro\captionlabelfont\itshape}
199 \DeclareOption{sl}{\g@addto@macro\captionlabelfont\slshape}
200 \DeclareOption{sc}{\g@addto@macro\captionlabelfont\scshape}
201 \DeclareOption{md}{\g@addto@macro\captionlabelfont\mdseries}
202 \DeclareOption{bf}{\g@addto@macro\captionlabelfont\bfseries}
203 \DeclareOption{rm}{\g@addto@macro\captionlabelfont\rmfamily}
204 \DeclareOption{sf}{\g@addto@macro\captionlabelfont\sffamily}
205 \DeclareOption{tt}{\g@addto@macro\captionlabelfont\ttfamily}
206 \DeclareOption{oneline}{\onelinecaptionstrue}
207 \DeclareOption{nooneline}{\onelinecaptionsfalse}
208 \newcommand*\caption@setpackage[1]{\@namedef{caption@pkt@#1}}
209 \@onlypreamble\caption@setpackage
210 \DeclareOption{float}{%
211 \caption@twozerofalse\caption@setpackage{float}{1}}
212 \DeclareOption{longtable}{%
213 \caption@twozerofalse\caption@setpackage{longtable}{1}}
214 \DeclareOption{subfigure}{%
215 \caption@twozerofalse\caption@setpackage{subfigure}{1}}
216 \DeclareOption{none}{%
217 \caption@twozerofalse
218 \caption@setpackage{float}{0}\caption@setpackage{longtable}{0}%
219 \caption@setpackage{subfigure}{0}}
220 \DeclareOption{all}{\ExecuteOptions{float,longtable,subfigure}}
221 \newif\ifcaption@ruled
222 \DeclareOption{ruled}{\caption@ruledtrue}
223 \DeclareOption{boxed}{}
224 \DeclareOption{ignoreLTcapwidth}{\ignoreLTcapwidthtrue}
225 \newif\ifcaption@twozero
226 \normalcaptionparams
227 \ExecuteOptions{none,normal}
228 \caption@twozerotrue
229 \ProcessOptions*
230 \ifcaption@twozero
231 \PackageInfo{caption2}{Running in caption2 v2.0 compatibility mode}
232 \fi
233 \def\captionof{\@ifstar{\caption@of{\caption*}}{\caption@of\caption}}
234 \newcommand*\caption@of[2]{\def\@captype{#2}#1}
235 \@ifundefined{abovecaptionskip}{%
236 \newlength\abovecaptionskip\setlength\abovecaptionskip{10\p@}}{}
237 \@ifundefined{belowcaptionskip}{%
238 \newlength\belowcaptionskip\setlength\belowcaptionskip{0\p@}}{}
239 \newdimen\captionlinewidth
240 \newdimen\realcaptionwidth
241 \newcommand*\usecaptionmargin{%
242 \ifcaptionwidth
243 \leftskip\captionlinewidth
244 \advance\leftskip by -\captionwidth
245 \divide\leftskip by 2
246 \rightskip\leftskip
247 \captionlinewidth\captionwidth
248 \else
249 \leftskip\captionmargin
250 \rightskip\captionmargin
251 \advance\captionlinewidth by -2\captionmargin
252 \fi
253 \realcaptionwidth\captionlinewidth}
254 \newcommand\onelinecaption[1]{%
255 \let\next\@firstofone
256 \ifonelinecaptions
257 \sbox\@tempboxa{#1}%
258 \ifdim\wd\@tempboxa >\captionlinewidth
259 \else
260 \def\next{{\centering\usebox\@tempboxa\par}\@gobble}%
261 \fi
262 \fi\next}
263 \newcommand*\usecaptionstyle[1]{%
264 \@ifundefined{captiontext}{%
265 \captiontwo@Error
266 [The usage of \protect#1 is only
267 allowed inside code declared with\MessageBreak \protect\defcaptionstyle,
268 \protect\newcaptionstyle \space or \protect\renewcaptionstyle.\space]%
269 {You can't use \protect#1 in normal text}%
270 }{%
271 \@ifundefined{caption@@#1}%
272 {\captiontwo@Error{Caption style `#1' undefined}}%
273 {\let\caption@make\caption@makecaption
274 \@nameuse{caption@@#1}}%
275 }}
276 \renewcommand\@makecaption[2]{%
277 \vskip\abovecaptionskip
278 \captionlinewidth\hsize
279 \realcaptionwidth\hsize
280 \def\captionlabel{#1}%
281 \def\captiontext{#2}%
282 \usecaptionstyle\caption@style
283 \vskip\belowcaptionskip}
284 \newcommand\caption@ifpackage[3]{%
285 \ifcaption@twozero
286 \let\next\@firstofone
287 \else\if1\@nameuse{caption@pkt@#1}%
288 \def\next{\@ifpackageloaded{#1}\@firstofone\AtBeginDocument}%
289 \else
290 \PackageInfo{caption2}{#1 package is disabled}%
291 #3%
292 \let\next\@gobble
293 \fi\fi
294 \@nameundef{caption@pkt@#1}%
295 \next{%
296 \@ifpackageloaded{#1}{%
297 \PackageInfo{caption2}{#1 package is loaded}%
298 #2}{%
299 \PackageInfo{caption2}{#1 package is not loaded}%
300 #3}}}
301 \@onlypreamble\caption@ifpackage
302 \caption@ifpackage{float}{%
303 \newcommand\caption@floatc[3]{%
304 \ifx\captionlabelfont\@empty
305 \let\captionlabelfont\@fs@cfont
306 \fi
307 \captionlinewidth\hsize
308 \realcaptionwidth\hsize
309 \def\captionlabel{#2}%
310 \def\captiontext{#3}%
311 \usecaptionstyle{#1}}%
312 \renewcommand*\floatc@plain{\caption@floatc{\caption@style}}%
313 \ifcaption@ruled
314 \dummycaptionstyle{ruled}{\onelinecaptionsfalse\setcaptionmargin{\z@}}%
315 \else
316 \newcaptionstyle{ruled}{%
317 \ifcaptionlabel
318 {\@fs@cfont\captionlabel}\space%
319 \fi\captiontext\par}%
320 \fi
321 \renewcommand*\floatc@ruled{\caption@floatc{ruled}}%
322 \renewcommand*\caption@of[2]{%
323 \def\@captype{#2}%
324 \@ifundefined{fst@#2}{}{%
325 \@nameuse{fst@#2}%
326 \@ifundefined{@float@setevery}{}{\@float@setevery{#2}}%
327 \let\caption@fs@capt\@fs@capt
328 \let\@fs@capt\caption@of@float}%
329 #1}%
330 \newcommand\caption@of@float[2]{\egroup
331 \vskip\abovecaptionskip
332 \normalsize\caption@fs@capt{#1}{#2}%
333 \vskip\belowcaptionskip
334 \bgroup}%
335 }{}
336 \caption@ifpackage{longtable}{%
337 \dummycaptionstyle{longtable}{}%
338 \renewcommand\LT@makecaption[3]{%
339 \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\hsize{%
340 \ifignoreLTcapwidth
341 \else
342 \setcaptionwidth\LTcapwidth
343 \fi
344 \captionlinewidth\hsize
345 \realcaptionwidth\hsize
346 \captionlabelfalse#1\captionlabeltrue
347 \def\captionlabel{#2}%
348 \def\captiontext{#3}%
349 \usecaptionstyle{longtable}%
350 \endgraf\vskip\baselineskip}%
351 \hss}}}%
352 }{}
353 \newcommand*\setsubcapstyle{%
354 \ifsubcaphang
355 \ifsubcapcenter
356 \subcapstyle{hang+center}%
357 \else\ifsubcapcenterlast
358 \subcapstyle{hang+centerlast}%
359 \else\ifsubcapraggedright
360 \subcapstyle{hang+flushleft}%
361 \else
362 \subcapstyle{hang}%
363 \fi\fi\fi
364 \else\ifsubcapcenter
365 \subcapstyle{center}%
366 \else\ifsubcapcenterlast
367 \subcapstyle{centerlast}%
368 \else\ifsubcapraggedright
369 \subcapstyle{flushleft}%
370 \else
371 \subcapstyle{normal}%
372 \fi\fi\fi\fi}
373 \AtBeginDocument{%
374 \@ifundefined{subcapraggedrightfalse}{%
375 \newif\ifsubcapraggedright}{}}
376 \newcommand\caption@makesubcaption[2]{%
377 \renewcommand*\captionfont{\subcapsize\subcapfont}%
378 \renewcommand*\captionlabelfont{\normalfont\subcapsize\subcaplabelfont}%
379 \let\captionlabeldelim\subcaplabeldelim
380 \let\captionlabelsep\subcaplabelsep
381 \ifsubfigcapwidth
382 \setcaptionwidth\subfigcapwidth
383 \else
384 \setcaptionmargin\subfigcapmargin
385 \fi
386 \setlength\captionmargin\subfigcapmargin
387 \setlength\captionwidth\subfigcapwidth
388 \captionindent\subcapindent
389 \ifsubcapnooneline
390 \onelinecaptionsfalse
391 \else
392 \onelinecaptionstrue
393 \fi
394 \hbox to\@tempdima{%
395 \caption@subfig@hss\parbox[t]\@tempdima{%
396 \captionlinewidth\@tempdima
397 \realcaptionwidth\@tempdima
398 \captionlabeltrue
399 \def\captionlabel{#1}%
400 \def\captiontext{\ignorespaces #2}%
401 \usecaptionstyle\caption@substyle}%
402 \caption@subfig@hss}}
403 \caption@ifpackage{subfigure}{%
404 \ifx\subcapfont\@undefined
405 \PackageInfo{caption2}{subfigure package v2.0 detected}%
406 \let\subcapfont\@empty
407 \newcommand*\subfigcapwidth{\z@}%
408 \newcommand*\setsubcapmargin{%
409 \subfigcapwidthfalse
410 \renewcommand*\subfigcapmargin}%
411 \newcommand*\setsubcapwidth{%
412 \subfigcapwidthtrue
413 \renewcommand*\subfigcapwidth}%
414 \newcommand*\subcaplabelsep{\space}%
415 \let\caption@subfig@hss\hfil
416 \else
417 \PackageInfo{caption2}{subfigure package v2.1 (or newer) detected}%
418 \newdimen\subfigcapwidth
419 \newcommand*\setsubcapmargin{%
420 \subfigcapwidthfalse
421 \setlength\subfigcapmargin}%
422 \newcommand*\setsubcapwidth{%
423 \subfigcapwidthtrue
424 \setlength\subfigcapwidth}%
425 \newcommand*\subcaplabelsep{\hskip\subfiglabelskip}%
426 \let\caption@subfig@hss\hss
427 \fi
428 \newif\ifsubfigcapwidth
429 \newdimen\subcapindent
430 \newcommand*\subcaplabeldelim{}%
431 \newcommand*\subcapstyle[1]{%
432 \expandafter\ifx\csname caption@@#1\endcsname\relax
433 \captiontwo@Error{Undefined caption style `#1'}%
434 \else
435 \def\caption@substyle{#1}%
436 \fi}%
437 \setsubcapstyle
438 \renewcommand*\@thesubfigure{\thesubfigure}%
439 \renewcommand*\@thesubtable{\thesubtable}%
440 \let\@makesubfigurecaption\caption@makesubcaption
441 \let\@makesubtablecaption\caption@makesubcaption
442 }{%
443 \let\setsubcapstyle\@undefined
444 \let\caption@makesubcaption\@undefined
445 }
446 \endinput
447 %%
448 %% End of file `caption2.sty'.