Debian Codegraph @

texmf-dist/tex/latex/caption/caption2_2005-10-03.sty

raw
1 %%
2 %% This is file `caption2_2005-10-03.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% fallback/v2.1/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 \ProvidesPackage{caption2}[2005/10/03 v2.1d Customising captions (AS)]
40 \newcommand*\captionfont{}
41 \newcommand*\captionlabelfont{}
42 \newcommand*\captionlabeldelim{}
43 \newcommand*\captionlabelsep{}
44 \newcommand*\captionsize{}
45 \newdimen\captionmargin
46 \newdimen\captionwidth
47 \newif\ifcaptionwidth
48 \newdimen\captionindent
49 \newif\ifcaptionlabel\captionlabeltrue
50 \newif\ifonelinecaptions
51 \newif\ifignoreLTcapwidth
52 \newcommand*\setcaptionmargin{%
53 \captionwidthfalse
54 \setlength\captionmargin}
55 \newcommand*\setcaptionwidth{%
56 \captionwidthtrue
57 \setlength\captionwidth}
58 \newcommand*\normalcaptionparams{%
59 \let\captionsize\@empty
60 \renewcommand*\captionfont{\captionsize}%
61 \let\captionlabelfont\@empty
62 \renewcommand*\captionlabeldelim{:}%
63 \renewcommand*\captionlabelsep{\space}%
64 \setcaptionmargin\z@\setlength\captionindent\z@
65 \onelinecaptionstrue}
66 \newcommand*\caption@eh{%
67 If you do not understand this error, please take a closer look\MessageBreak
68 at the documentation of the `caption2' package.\MessageBreak
69 \@ehc}
70 \newcommand*\defcaptionstyle[1]{%
71 \@namedef{caption@@#1}}
72 \newcommand*\newcaptionstyle[1]{%
73 \expandafter\ifx\csname caption@@#1\endcsname\relax
74 \expandafter\defcaptionstyle
75 \else
76 \PackageError{caption2}{Caption style `#1' already defined}{\caption@eh}%
77 \expandafter\@gobbletwo
78 \fi
79 {#1}}
80 \newcommand*\renewcaptionstyle[1]{%
81 \expandafter\ifx\csname caption@@#1\endcsname\relax
82 \PackageError{caption2}{Caption style `#1' undefined}{\caption@eh}%
83 \expandafter\@gobbletwo
84 \else
85 \expandafter\defcaptionstyle
86 \fi
87 {#1}}
88 \newcommand*\dummycaptionstyle[2]{%
89 \defcaptionstyle{#1}{%
90 \expandafter\ifx\csname caption@@\caption@style\expandafter\endcsname%
91 \csname caption@@#1\endcsname
92 \PackageError{caption2}{You can't use the caption style `#1' directy}{%
93 The caption style `#1' is only a dummy and does not really exists.%
94 \MessageBreak You have to redefine it (with \protect\renewcaptionstyle)
95 before you can select\MessageBreak it with \protect\captionstyle.
96 \space\caption@eh}%
97 \else
98 #2\usecaptionstyle\caption@style
99 \fi}}
100 \newcommand*\captionstyle[1]{%
101 \expandafter\ifx\csname caption@@#1\endcsname\relax
102 \PackageError{caption2}{Undefined caption style `#1'}{\caption@eh}%
103 \else
104 \def\caption@style{#1}%
105 \fi}
106 \newcaptionstyle{normal}{\caption@make{normal}}
107 \newcaptionstyle{center}{\caption@make{center}}
108 \newcaptionstyle{centerlast}{\caption@make{centerlast}}
109 \newcaptionstyle{flushleft}{\caption@make{flushleft}}
110 \newcaptionstyle{flushright}{\caption@make{flushright}}
111 \newcaptionstyle{hang}{\caption@make{hang}}
112 \newcaptionstyle{hang+center}{\caption@make{hang@center}}
113 \newcaptionstyle{hang+centerlast}{\caption@make{hang@centerlast}}
114 \newcaptionstyle{hang+flushleft}{\caption@make{hang@flushleft}}
115 \newcaptionstyle{indent}{\caption@make{indent}}
116 \newcommand*\caption@makecaption[1]{%
117 \usecaptionmargin
118 \ifcaptionlabel
119 \def\caption@label{%
120 {\captionlabelfont\captionlabel\captionlabeldelim}\captionlabelsep}%
121 \else
122 \let\caption@label\@empty
123 \fi
124 \captionfont
125 \onelinecaption
126 {\caption@label\captiontext}%
127 {\parbox[b]\captionlinewidth{\strut\@nameuse{caption@@@#1}\par}\par}}
128 \newcommand*\caption@make{\caption@makecaption}
129 \newcommand*\caption@@@normal{%
130 \caption@label\captiontext}
131 \newcommand*\caption@@@center{%
132 \centering\caption@label\captiontext}%
133 \newcommand*\caption@centerlast{%
134 \advance\leftskip by 0pt plus 1fil%
135 \advance\rightskip by 0pt plus -1fil%
136 \parfillskip0pt plus 2fil\relax}
137 \newcommand*\caption@@@centerlast{%
138 \caption@centerlast\caption@label\captiontext}
139 \newcommand*\caption@@@flushleft{%
140 \raggedright\caption@label\captiontext}%
141 \newcommand*\caption@@@flushright{%
142 \raggedleft\caption@label\captiontext}%
143 \newcommand*\caption@@@hang{%
144 \sbox\@tempboxa{\caption@label}%
145 \hangindent\wd\@tempboxa\noindent
146 \usebox\@tempboxa\caption@hangplus\captiontext}
147 \newcommand*\caption@hangplus{}
148 \newcommand*\caption@@@hang@center{%
149 \let\caption@hangplus\centering\caption@@@hang}
150 \newcommand*\caption@@@hang@centerlast{%
151 \let\caption@hangplus\caption@centerlast\caption@@@hang}
152 \newcommand*\caption@@@hang@flushleft{%
153 \let\caption@hangplus\raggedright\caption@@@hang}
154 \newcommand*\caption@@@indent{%
155 \hangindent\captionindent\noindent
156 \caption@label\captiontext}
157 \DeclareOption{normal}{\captionstyle{normal}}
158 \DeclareOption{center}{\captionstyle{center}}
159 \DeclareOption{centerlast}{\captionstyle{centerlast}}
160 \DeclareOption{flushleft}{\captionstyle{flushleft}}
161 \DeclareOption{flushright}{\captionstyle{flushright}}
162 \DeclareOption{anne}{\ExecuteOptions{centerlast}}
163 \DeclareOption{hang}{\captionstyle{hang}}
164 \DeclareOption{hang+center}{\captionstyle{hang+center}}
165 \DeclareOption{hang+centerlast}{\captionstyle{hang+centerlast}}
166 \DeclareOption{hang+flushleft}{\captionstyle{hang+flushleft}}
167 \DeclareOption{isu}{\ExecuteOptions{hang}}
168 \DeclareOption{indent}{\captionstyle{indent}}
169 \DeclareOption{scriptsize}{\g@addto@macro\captionsize\scriptsize}
170 \DeclareOption{footnotesize}{\g@addto@macro\captionsize\footnotesize}
171 \DeclareOption{small}{\g@addto@macro\captionsize\small}
172 \DeclareOption{normalsize}{\g@addto@macro\captionsize\normalsize}
173 \DeclareOption{large}{\g@addto@macro\captionsize\large}
174 \DeclareOption{Large}{\g@addto@macro\captionsize\Large}
175 \DeclareOption{up}{\g@addto@macro\captionlabelfont\upshape}
176 \DeclareOption{it}{\g@addto@macro\captionlabelfont\itshape}
177 \DeclareOption{sl}{\g@addto@macro\captionlabelfont\slshape}
178 \DeclareOption{sc}{\g@addto@macro\captionlabelfont\scshape}
179 \DeclareOption{md}{\g@addto@macro\captionlabelfont\mdseries}
180 \DeclareOption{bf}{\g@addto@macro\captionlabelfont\bfseries}
181 \DeclareOption{rm}{\g@addto@macro\captionlabelfont\rmfamily}
182 \DeclareOption{sf}{\g@addto@macro\captionlabelfont\sffamily}
183 \DeclareOption{tt}{\g@addto@macro\captionlabelfont\ttfamily}
184 \DeclareOption{oneline}{\onelinecaptionstrue}
185 \DeclareOption{nooneline}{\onelinecaptionsfalse}
186 \newcommand*\caption@package[1]{\@namedef{caption@pkt@#1}}
187 \DeclareOption{float}{\caption@twozerofalse\caption@package{float}{1}}
188 \DeclareOption{longtable}{\caption@twozerofalse\caption@package{longtable}{1}}
189 \DeclareOption{subfigure}{\caption@twozerofalse\caption@package{subfigure}{1}}
190 \DeclareOption{none}{\caption@twozerofalse
191 \caption@package{float}{0}\caption@package{longtable}{0}%
192 \caption@package{subfigure}{0}}
193 \DeclareOption{all}{\ExecuteOptions{float,longtable,subfigure}}
194 \newif\ifcaption@ruled
195 \DeclareOption{ruled}{\caption@ruledtrue}
196 \DeclareOption{boxed}{}
197 \DeclareOption{ignoreLTcapwidth}{\ignoreLTcapwidthtrue}
198 \DeclareOption{debug}{\caption@debugtrue}
199 \newif\ifcaption@debug
200 \newif\ifcaption@twozero
201 \normalcaptionparams
202 \ExecuteOptions{none,normal}
203 \caption@twozerotrue
204 \ProcessOptions*
205 \ifcaption@twozero
206 \PackageInfo{caption2}{Running in caption2 v2.0 compatibility mode}
207 \fi
208 \def\captionof{\@ifstar{\caption@of{\caption*}}{\caption@of\caption}}
209 \newcommand*\caption@of[2]{\def\@captype{#2}#1}
210 \@ifundefined{abovecaptionskip}{%
211 \newlength\abovecaptionskip\setlength\abovecaptionskip{10\p@}}{}
212 \@ifundefined{belowcaptionskip}{%
213 \newlength\belowcaptionskip\setlength\belowcaptionskip{0\p@}}{}
214 \newdimen\captionlinewidth
215 \newdimen\realcaptionwidth
216 \newcommand*\usecaptionmargin{%
217 \ifcaptionwidth
218 \leftskip\captionlinewidth
219 \advance\leftskip by -\captionwidth
220 \divide\leftskip by 2
221 \rightskip\leftskip
222 \captionlinewidth\captionwidth
223 \else
224 \leftskip\captionmargin
225 \rightskip\captionmargin
226 \advance\captionlinewidth by -2\captionmargin
227 \fi
228 \realcaptionwidth\captionlinewidth}
229 \newcommand\onelinecaption[1]{%
230 \let\next\@firstofone
231 \ifonelinecaptions
232 \sbox\@tempboxa{#1}%
233 \ifdim\wd\@tempboxa >\captionlinewidth
234 \else
235 \def\next{{\centering\usebox\@tempboxa\par}\@gobble}%
236 \fi
237 \fi\next}
238 \newcommand*\usecaptionstyle[1]{%
239 \@ifundefined{captiontext}{%
240 \PackageError{caption2}{You can't use \protect#1
241 in normal text}{The usage of \protect#1 is only
242 allowed inside code declared with\MessageBreak \protect\defcaptionstyle,
243 \protect\newcaptionstyle \space or \protect\renewcaptionstyle.
244 \space\caption@eh}
245 }{%
246 \@ifundefined{caption@@#1}%
247 {\PackageError{caption2}{Caption style `#1' undefined}{\caption@eh}}%
248 {\@nameuse{caption@@#1}}%
249 }}
250 \renewcommand\@makecaption[2]{%
251 \vskip\abovecaptionskip
252 \captionlinewidth\hsize
253 \realcaptionwidth\hsize
254 \def\captionlabel{#1}%
255 \def\captiontext{#2}%
256 \usecaptionstyle\caption@style
257 \vskip\belowcaptionskip}
258 \renewcommand*\caption@package[3]{%
259 \if1\@nameuse{caption@pkt@#1}%
260 \@ifundefined{#2}%
261 {\let\next\AtBeginDocument}%
262 {\let\next\@firstofone}%
263 \else\ifcaption@twozero
264 \@ifundefined{#2}%
265 {#3\let\next\@gobble}%
266 {\let\next\@firstofone}%
267 \else
268 #3\let\next\@gobble
269 \fi\fi
270 \expandafter\let\csname caption@pkt@#1\endcsname\undefined
271 \ifcaption@debug
272 \ifx\next\@gobble\PackageInfo{caption2}{#1 => gobble}%
273 \else\ifx\next\@firstofone\PackageInfo{caption2}{#1 => firstofone}%
274 \else\ifx\next\AtBeginDocument\PackageInfo{caption2}{#1 => AtBeginDocument}%
275 \fi\fi\fi
276 \fi
277 \next}
278 \caption@package{float}{floatc@plain}{}{%
279 \ifx\floatc@plain\relax
280 \PackageWarning{caption2}{%
281 Option `float' was set but there is no float package loaded}
282 \else
283 \PackageInfo{caption2}{float package v1.2 (or newer) detected}
284 \newcommand\caption@floatc[3]{%
285 \ifx\captionlabelfont\@empty
286 \let\captionlabelfont\@fs@cfont
287 \fi
288 \captionlinewidth\hsize
289 \realcaptionwidth\hsize
290 \def\captionlabel{#2}%
291 \def\captiontext{#3}%
292 \usecaptionstyle{#1}}
293 \renewcommand*\floatc@plain{\caption@floatc{\caption@style}}
294 \ifcaption@ruled
295 \dummycaptionstyle{ruled}{\onelinecaptionsfalse\setcaptionmargin{\z@}}%
296 \else
297 \newcaptionstyle{ruled}{%
298 \ifcaptionlabel
299 {\@fs@cfont\captionlabel}\space%
300 \fi\captiontext\par}%
301 \fi
302 \renewcommand*\floatc@ruled{\caption@floatc{ruled}}
303 \renewcommand*\caption@of[2]{\def\@captype{#2}%
304 \@ifundefined{fst@#2}{}{%
305 \@nameuse{fst@#2}%
306 \@ifundefined{@float@setevery}{}{\@float@setevery{#2}}%
307 \let\caption@fs@capt\@fs@capt
308 \let\@fs@capt\caption@of@float}%
309 #1}
310 \newcommand\caption@of@float[2]{\egroup
311 \vskip\abovecaptionskip
312 \normalsize\caption@fs@capt{#1}{#2}%
313 \vskip\belowcaptionskip
314 \bgroup}%
315 \fi}
316 \caption@package{longtable}{LT@makecaption}{}{%
317 \ifx\LT@makecaption\relax
318 \PackageWarning{caption2}{%
319 Option `longtable' was set but there is no longtable package loaded}
320 \else
321 \PackageInfo{caption2}{longtable package v3.15 (or newer) detected}
322 \dummycaptionstyle{longtable}{}
323 \renewcommand\LT@makecaption[3]{%
324 \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\hsize{%
325 \ifignoreLTcapwidth
326 \else
327 \setcaptionwidth\LTcapwidth
328 \fi
329 \captionlinewidth\hsize
330 \realcaptionwidth\hsize
331 \captionlabelfalse#1\captionlabeltrue
332 \def\captionlabel{#2}%
333 \def\captiontext{#3}%
334 \usecaptionstyle{longtable}%
335 \endgraf\vskip\baselineskip}%
336 \hss}}}
337 \fi}
338 \newcommand*\setsubcapstyle{%
339 \@ifundefined{subcapraggedrightfalse}{%
340 \newif\ifsubcapraggedright}{}%
341 \ifsubcaphang
342 \ifsubcapcenter
343 \subcapstyle{hang+center}%
344 \else\ifsubcapcenterlast
345 \subcapstyle{hang+centerlast}%
346 \else\ifsubcapraggedright
347 \subcapstyle{hang+flushleft}%
348 \else
349 \subcapstyle{hang}%
350 \fi\fi\fi
351 \else\ifsubcapcenter
352 \subcapstyle{center}%
353 \else\ifsubcapcenterlast
354 \subcapstyle{centerlast}%
355 \else\ifsubcapraggedright
356 \subcapstyle{flushleft}%
357 \else
358 \subcapstyle{normal}%
359 \fi\fi\fi\fi}
360 \newcommand\caption@makesubcaption[2]{%
361 \renewcommand*\captionfont{\subcapsize\subcapfont}%
362 \renewcommand*\captionlabelfont{\normalfont\subcapsize\subcaplabelfont}%
363 \let\captionlabeldelim\subcaplabeldelim
364 \let\captionlabelsep\subcaplabelsep
365 \ifsubfigcapwidth\captionwidthtrue\else\captionwidthfalse\fi
366 \setlength\captionmargin\subfigcapmargin
367 \setlength\captionwidth\subfigcapwidth
368 \captionindent\subcapindent
369 \ifsubcapnooneline\onelinecaptionsfalse\else\onelinecaptionstrue\fi
370 \hbox to\@tempdima{%
371 \caption@subfig@hss\parbox[t]\@tempdima{%
372 \captionlinewidth\@tempdima
373 \realcaptionwidth\@tempdima
374 \captionlabeltrue
375 \def\captionlabel{#1}%
376 \def\captiontext{\ignorespaces #2}%
377 \usecaptionstyle\caption@substyle}%
378 \caption@subfig@hss}}
379 \caption@package{subfigure}{@makesubfigurecaption}{%
380 \let\setsubcapstyle\undefined
381 \let\caption@makesubcaption\undefined}{%
382 \ifx\@makesubfigurecaption\relax
383 \PackageWarning{caption2}{%
384 Option `subfigure' was set but there is no subfigure package loaded}
385 \let\setsubcapstyle\undefined
386 \let\caption@makesubcaption\undefined
387 \else
388 \ifx\subcapfont\undefined
389 \PackageInfo{caption2}{subfigure package v2.0 detected}
390 \let\subcapfont\@empty
391 \newcommand*\subfigcapwidth{\z@}
392 \newcommand*\setsubcapmargin{%
393 \subfigcapwidthfalse
394 \renewcommand*\subfigcapmargin}
395 \newcommand*\setsubcapwidth{%
396 \subfigcapwidthtrue
397 \renewcommand*\subfigcapwidth}
398 \newcommand*\subcaplabelsep{\space}
399 \let\caption@subfig@hss\hfil
400 \else
401 \PackageInfo{caption2}{subfigure package v2.1 (or newer) detected}
402 \newdimen\subfigcapwidth
403 \newcommand*\setsubcapmargin{%
404 \subfigcapwidthfalse
405 \setlength\subfigcapmargin}
406 \newcommand*\setsubcapwidth{%
407 \subfigcapwidthtrue
408 \setlength\subfigcapwidth}
409 \newcommand*\subcaplabelsep{\hskip\subfiglabelskip}
410 \let\caption@subfig@hss\hss
411 \fi
412 \newif\ifsubfigcapwidth
413 \newdimen\subcapindent
414 \newcommand*\subcaplabeldelim{}
415 \newcommand*\subcapstyle[1]{%
416 \expandafter\ifx\csname caption@@#1\endcsname\relax
417 \PackageError{caption2}{Undefined caption style `#1'}{\caption@eh}%
418 \else
419 \def\caption@substyle{#1}%
420 \fi}
421 \setsubcapstyle
422 \renewcommand*\@thesubfigure{\thesubfigure}
423 \renewcommand*\@thesubtable{\thesubtable}
424 \let\@makesubfigurecaption\caption@makesubcaption
425 \let\@makesubtablecaption\caption@makesubcaption
426 \fi}
427 \let\caption@package\undefined
428 \endinput
429 %%
430 %% End of file `caption2_2005-10-03.sty'.