summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/caption/caption3.sty
blob: 75bed31ea4b78f1e3799f4c561fcf56c8cc320d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
%%
%% This is file `caption3.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% caption.dtx  (with options: `kernel')
%% 
%% Copyright (C) 1994-2005 Axel Sommerfeldt (caption@sommerfeldt.net)
%% 
%% --------------------------------------------------------------------------
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2003/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% This Current Maintainer of this work is Axel Sommerfeldt.
%% 
%% This work consists of the files caption.ins, caption.dtx,
%% caption2.dtx, caption.xml, and anleitung.tex and the derived files
%% caption.sty, caption2.sty, caption3.sty, and manual.tex.
%% 
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{caption3}[2005/06/11 v3.0f caption3 kernel (AS)]
\providecommand*\@nameundef[1]{%
  \expandafter\let\csname #1\endcsname\@undefined}
\providecommand\l@addto@macro[2]{%
  \begingroup
    \toks@\expandafter{#1#2}%
    \edef\@tempa{\endgroup\def\noexpand#1{\the\toks@}}%
  \@tempa}
\def\bothIfFirst#1#2{%
  \protected@edef\caption@tempa{#1}%
  \ifx\caption@tempa\@empty\else
    #1#2%
  \fi}
\def\bothIfSecond#1#2{%
  \protected@edef\caption@tempa{#2}%
  \ifx\caption@tempa\@empty\else
    #1#2%
  \fi}
\def\caption@ifinlist#1#2{%
  \let\next\@secondoftwo
  \edef\caption@tempa{#1}%
  \@for\caption@tempb:={#2}\do{%
    \ifx\caption@tempa\caption@tempb
      \let\next\@firstoftwo
    \fi}%
  \next}
\def\caption@setbool#1#2{%
  \caption@ifinlist{#2}{1,true,yes,on}{%
    \expandafter\let\csname caption@if#1\endcsname\@firstoftwo
  }{\caption@ifinlist{#2}{0,false,no,off}{%
    \expandafter\let\csname caption@if#1\endcsname\@secondoftwo
  }{%
    \PackageError{caption}{Undefined boolean value `#2'}{\caption@eh}%
  }}}
\def\caption@ifbool#1{\@nameuse{caption@if#1}}
\RequirePackage{keyval}[1997/11/10]
\providecommand*\undefine@key[2]{%
  \@nameundef{KV@#1@#2}\@nameundef{KV@#1@#2@default}}
\newcommand\DeclareCaptionOption{%
  \@ifstar{\caption@declareoption\AtEndOfPackage}%
          {\caption@declareoption\@gobble}}
\newcommand*\caption@declareoption[2]{%
  #1{\undefine@key{caption}{#2}}\define@key{caption}{#2}}
\@onlypreamble\DeclareCaptionOption
\@onlypreamble\caption@declareoption
\def\captionsetup{\@ifnextchar[\caption@setuptype\caption@setup}
\def\caption@setuptype[#1]#2{%
  \@ifundefined{caption@typ@#1}%
    {\@namedef{caption@typ@#1}{#2}}%
    {\expandafter\l@addto@macro\csname caption@typ@#1\endcsname{,#2}}}
\def\caption@setup{\setkeys{caption}}
\def\caption@settype#1{%
  \@ifundefined{caption@typ@#1}{}{%
    \caption@esetup{\csname caption@typ@#1\endcsname}}}
\def\caption@esetup#1{%
  \edef\caption@tempa{\noexpand\caption@setup{#1}}%
  \caption@tempa}
\newcommand*\clearcaptionsetup[1]{\@nameundef{caption@typ@#1}}
\newcommand*\showcaptionsetup[2][\@firstofone]{%
  \GenericWarning{}{%
    #1 Caption Info: KV list on `#2'\MessageBreak
    #1 Caption Data: (%
    \@ifundefined{caption@typ@#2}{%
      % Empty -- print nothing.
    }{%
      \@nameuse{caption@typ@#2}%
    }%
    )}}
\newcommand\caption@eh{%
  If you do not understand this error, please take a closer look\MessageBreak
  at the documentation of the `caption' package.\MessageBreak
  \@ehc}
\newdimen\captionmargin
\newdimen\captionwidth
\newif\ifcaption@width
\DeclareCaptionOption{margin}{\caption@setmargin{#1}}
\DeclareCaptionOption{width}{\caption@setwidth{#1}}
\newcommand\caption@setmargin{%
  \caption@widthfalse
  \setlength\captionmargin}
\newcommand\caption@setwidth{%
  \caption@widthtrue
  \setlength\captionwidth}
\newdimen\captionindent
\newdimen\captionparindent
\newdimen\captionhangindent
\DeclareCaptionOption{indent}[\leftmargini]{\setlength\captionindent{#1}}% obsolete!
\DeclareCaptionOption{indention}[\leftmargini]{\setlength\captionindent{#1}}
\DeclareCaptionOption{parindent}[\parindent]{\setlength\captionparindent{#1}}% changed v3.0b
\DeclareCaptionOption{hangindent}[0pt]{\setlength\captionhangindent{#1}}% changed v3.0b
\newcommand*\DeclareCaptionStyle[1]{%
  \@ifnextchar[{\caption@declarestyle{#1}}{\caption@declarestyle{#1}[]}}
\def\caption@declarestyle#1[#2]#3{%
  \global\@namedef{caption@sls@#1}{#2}%
  \global\@namedef{caption@sty@#1}{#3}}
\@onlypreamble\DeclareCaptionStyle
\@onlypreamble\caption@declarestyle
\DeclareCaptionOption{style}{\caption@setstyle{#1}}
\newcommand\caption@setstyle{%
  \@ifstar{\caption@@setstyle\@gobble}{\caption@@setstyle\@firstofone}}
\newcommand*\caption@@setstyle[2]{%
  \@ifundefined{caption@sty@#2}%
    {#1{\PackageError{caption}{Undefined caption style `#2'}{\caption@eh}}}%
{\expandafter\let\expandafter\caption@sls\csname caption@sls@#2\endcsname
     \caption@setdefault\caption@esetup{\csname caption@sty@#2\endcsname}}}
\newcommand\caption@setdefault{\captionsetup{%
  format=default,labelformat=default,labelsep=default,justification=default,%
  font=default,labelfont=default,textfont=default,%
  margin=0pt,indention=0pt,parindent=0pt,hangindent=0pt,singlelinecheck}}
\DeclareCaptionStyle{default}[indent=0pt,justification=centering]{}
\def\DeclareCaptionFormat{%
  \@ifstar{\caption@declareformat\@gobble}{\caption@declareformat\@firstofone}}
\newcommand\caption@declareformat[3]{%
  \global\expandafter\let\csname caption@ifh@#2\endcsname#1%
  \global\long\expandafter\def\csname caption@fmt@#2\endcsname##1##2##3{#3}}
\@onlypreamble\DeclareCaptionFormat
\@onlypreamble\caption@declareformat
\DeclareCaptionOption{format}{\caption@setformat{#1}}
\newcommand*\caption@setformat[1]{%
  \@ifundefined{caption@fmt@#1}%
    {\PackageError{caption}{Undefined caption format `#1'}{\caption@eh}}%
    {\expandafter\let\expandafter\caption@ifh\csname caption@ifh@#1\endcsname
     \expandafter\let\expandafter\caption@fmt\csname caption@fmt@#1\endcsname}}
\DeclareCaptionFormat{@normal}{#1#2#3\par}
\DeclareCaptionFormat{hang}{%
  \@hangfrom{#1#2}%
  \advance\captionparindent\hangindent
  \advance\captionhangindent\hangindent
  \caption@@par
  #3\par}
\def\caption@fmt@default{\caption@fmt@@normal}
\def\caption@ifh@default{\caption@ifh@@normal}% bugfix v3.0e (05-04-28)
\newcommand*\DeclareCaptionLabelFormat[2]{%
  \global\expandafter\def\csname caption@lfmt@#1\endcsname##1##2{#2}}
\@onlypreamble\DeclareCaptionLabelFormat
\DeclareCaptionOption{labelformat}{\caption@setlabelformat{#1}}
\newcommand*\caption@setlabelformat[1]{%
  \@ifundefined{caption@lfmt@#1}%
    {\PackageError{caption}{Undefined caption label format `#1'}{\caption@eh}}%
    {\expandafter\let\expandafter\caption@lfmt\csname caption@lfmt@#1\endcsname}}
\DeclareCaptionLabelFormat{empty}{}
\DeclareCaptionLabelFormat{simple}{\bothIfFirst{#1}{\nobreakspace}#2}
\DeclareCaptionLabelFormat{parens}{\bothIfFirst{#1}{\nobreakspace}(#2)}
\def\caption@lfmt@default{\caption@lfmt@simple}
\newcommand\DeclareCaptionLabelSeparator[2]{%
  \global\long\@namedef{caption@lsep@#1}{#2}}
\@onlypreamble\DeclareCaptionLabelSeparator
\DeclareCaptionOption{labelsep}{\caption@setlabelseparator{#1}}
\DeclareCaptionOption{labelseparator}{\caption@setlabelseparator{#1}}
\newcommand*\caption@setlabelseparator[1]{%
  \@ifundefined{caption@lsep@#1}%
    {\PackageError{caption}{Undefined caption label separator `#1'}{\caption@eh}}%
    {\expandafter\let\expandafter\caption@lsep\csname caption@lsep@#1\endcsname}}
\DeclareCaptionLabelSeparator{none}{}
\DeclareCaptionLabelSeparator{colon}{: }
\DeclareCaptionLabelSeparator{period}{. }
\DeclareCaptionLabelSeparator{space}{ }
\DeclareCaptionLabelSeparator{quad}{\quad}
\DeclareCaptionLabelSeparator{newline}{\\}% 05-03-23 (v3.0f)
\def\caption@lsep@default{\caption@lsep@colon}
\newcommand*\DeclareCaptionJustification[2]{%
  \global\@namedef{caption@hj@#1}{#2}}
\@onlypreamble\DeclareCaptionJustification
\DeclareCaptionOption{justification}{\caption@setjustification{#1}}
\newcommand*\caption@setjustification[1]{%
  \@ifundefined{caption@hj@#1}%
    {\PackageError{caption}{Undefined caption justification `#1'}{\caption@eh}}%
    {\expandafter\let\expandafter\caption@hj\csname caption@hj@#1\endcsname}}
\DeclareCaptionJustification{justified}{}
\DeclareCaptionJustification{centering}{\centering}
\DeclareCaptionJustification{centerfirst}{\caption@centerfirst}
\DeclareCaptionJustification{centerlast}{\caption@centerlast}
\DeclareCaptionJustification{raggedleft}{\raggedleft}
\DeclareCaptionJustification{raggedright}{\raggedright}
\def\caption@hj@default{\caption@hj@justified}
\newcommand\caption@centerfirst{%
  \edef\caption@normaladjust{%
    \leftskip\the\leftskip
    \rightskip\the\rightskip
    \parfillskip\the\parfillskip\relax}%
  \leftskip\z@\@plus -1fil%
  \rightskip\z@\@plus 1fil%
  \parfillskip\z@skip
  \noindent\hskip\z@\@plus 2fil%
  \@setpar{\@@par\@restorepar\caption@normaladjust}}
\newcommand\caption@centerlast{%
  \leftskip\z@\@plus 1fil%
  \rightskip\z@\@plus -1fil%
  \parfillskip\z@\@plus 2fil\relax}
\DeclareCaptionJustification{Centering}{%
  \caption@ragged\Centering\centering}
\DeclareCaptionJustification{RaggedLeft}{%
  \caption@ragged\RaggedLeft\raggedleft}
\DeclareCaptionJustification{RaggedRight}{%
  \caption@ragged\RaggedRight\raggedright}
\newcommand*\caption@ragged[2]{%
  \@ifundefined{caption\string#1}{%
    \PackageWarning{caption}{%
      Cannot locate the `ragged2e' package, therefore\MessageBreak
      substituting \string#2 for \string#1\MessageBreak}%
    \global\@namedef{caption\string#1}}{}%
  #2}
\AtBeginDocument{\IfFileExists{ragged2e.sty}{%
  \RequirePackage{ragged2e}\let\caption@ragged\@firstoftwo}{}}
\newcommand\DeclareCaptionFont[2]{%
  \define@key{caption@fnt}{#1}[]{\g@addto@macro\caption@tempa{#2}}}
\@onlypreamble\DeclareCaptionFont
\DeclareCaptionOption{font}{\caption@setfont{font}{#1}}
\DeclareCaptionOption{labelfont}{\caption@setfont{labelfont}{#1}}
\DeclareCaptionOption{textfont}{\caption@setfont{textfont}{#1}}
\newcommand*\caption@setfont[2]{%
  \let\caption@tempa\@empty
  \begingroup
    \setkeys{caption@fnt}{#2}%
  \endgroup
  \expandafter\let\csname caption#1\endcsname\caption@tempa}
\DeclareCaptionFont{default}{}
\DeclareCaptionFont{scriptsize}{\scriptsize}
\DeclareCaptionFont{footnotesize}{\footnotesize}
\DeclareCaptionFont{small}{\small}
\DeclareCaptionFont{normalsize}{\normalsize}
\DeclareCaptionFont{large}{\large}
\DeclareCaptionFont{Large}{\Large}
\DeclareCaptionFont{up}{\upshape}
\DeclareCaptionFont{it}{\itshape}
\DeclareCaptionFont{sl}{\slshape}
\DeclareCaptionFont{sc}{\scshape}
\DeclareCaptionFont{md}{\mdseries}
\DeclareCaptionFont{bf}{\bfseries}
\DeclareCaptionFont{rm}{\rmfamily}
\DeclareCaptionFont{sf}{\sffamily}
\DeclareCaptionFont{tt}{\ttfamily}
\providecommand\captionsize{}
\DeclareCaptionOption{size}{\caption@setfont{size}{#1}}% changed v3.0a
\@ifundefined{abovecaptionskip}{%
  \newlength\abovecaptionskip\setlength\abovecaptionskip{10\p@}}{}
\@ifundefined{belowcaptionskip}{%
  \newlength\belowcaptionskip\setlength\belowcaptionskip{0\p@}}{}
\DeclareCaptionOption{aboveskip}{\setlength\abovecaptionskip{#1}}
\DeclareCaptionOption{belowskip}{\setlength\belowcaptionskip{#1}}
\DeclareCaptionOption{skip}{\setlength\abovecaptionskip{#1}}% new 3.0d
\DeclareCaptionOption{position}{\caption@setposition{#1}}
\newcommand*\caption@setposition[1]{%
  \caption@ifinlist{#1}{d,default}{%
    \def\caption@position{\caption@defaultpos}%
  }{\caption@ifinlist{#1}{t,top,above}{%
    \let\caption@position\@firstoftwo
  }{\caption@ifinlist{#1}{b,bottom,below}{%
    \let\caption@position\@secondoftwo
  }{\caption@ifinlist{#1}{a,auto}{%
    \let\caption@position\@undefined
  }{%
    \PackageError{caption}{Undefined caption position `#1'}{\caption@eh}%
  }}}}}
\let\caption@defaultpos\@secondoftwo
\newcommand\caption@iftop{% bugfixed v3.0a, improved v3.0d
  \ifx\caption@position\@undefined
    \expandafter\@secondoftwo
  \else
    \expandafter\caption@position
  \fi}
\newcommand\caption@fixposition{%
  \ifx\caption@position\@undefined
    \caption@autoposition
  \fi}
\newcommand\caption@autoposition{% bugfixed v3.0a
  \ifvmode
    \ifodd\caption@debug\relax
      \edef\caption@tempa{\the\prevdepth}%
      \PackageInfo{caption}{\protect\prevdepth=\caption@tempa}%
    \fi
    \ifdim\prevdepth>-\p@
      \let\caption@position\@secondoftwo
    \else
      \let\caption@position\@firstoftwo
    \fi
  \else
    \ifodd\caption@debug\relax
      \PackageInfo{caption}{no \protect\prevdepth}%
    \fi
    \let\caption@position\@secondoftwo
  \fi}
\newcommand\caption@beginhook{}
\newcommand\caption@endhook{}
\newcommand\AtBeginCaption{\l@addto@macro\caption@beginhook}
\newcommand\AtEndCaption{\l@addto@macro\caption@endhook}
\DeclareCaptionOption{parskip}[5pt]{\AtBeginCaption{\setlength\parskip{#1}}}
\DeclareCaptionOption{listof}{\caption@setbool{lof}{#1}}% new v3.0b
\DeclareCaptionOption{singlelinecheck}[1]{\caption@setbool{slc}{#1}}
\DeclareCaptionOption{strut}{\caption@setbool{strut}{#1}}% new v3.0d
\DeclareCaptionOption{debug}{\def\caption@debug{#1}}
\captionsetup{style=default,position=default,listof=1,strut=1,debug=0}
\newif\ifcaption@star
\newcommand\caption@make[2]{%
  \caption@@make{\caption@lfmt{#1}{#2}}}
\newcommand\caption@@make[2]{%
  \caption@beginhook
  \caption@calcmargin
  \caption@ifslc{%
    \ifx\caption@sls\@empty\else
      \caption@startslc
      \setbox\@tempboxa\hbox{\caption@@@make{#1}{#2}}%
      \ifdim\wd\@tempboxa >\captionwidth
        \caption@endslc
      \else
        \caption@endslc
        \caption@esetup\caption@sls
        \caption@calcmargin
      \fi
    \fi}{}%
  \@tempdima\captionmargin
  \caption@ifh{\advance\@tempdima by \captionindent}%
  \ifdim\@tempdima=\z@\else
    \hskip\@tempdima
  \fi
  \@tempdima\captionwidth
  \caption@ifh{\advance\@tempdima by -\captionindent}%
  \caption@startbox\@tempdima
    \caption@ifh{%
      \ifdim\captionindent=\z@
        \leavevmode
      \else
        \hskip-\captionindent
      \fi}%
    \caption@@@make{#1}{#2}%
  \caption@endbox
  \ifdim\captionmargin=\z@\else
    \hskip\captionmargin
  \fi
  \caption@endhook
  \global\caption@starfalse}
\newcommand\caption@calcmargin{%
  \ifcaption@width
    \captionmargin\hsize
    \advance\captionmargin by -\captionwidth
    \divide\captionmargin by 2
  \else
    \captionwidth\hsize
    \advance\captionwidth by -2\captionmargin
  \fi
  \ifodd\caption@debug\relax
    \PackageInfo{caption}{\protect\hsize=\the\hsize,
      \protect\margin=\the\captionmargin,
      \protect\width=\the\captionwidth}%
  \fi}
\newcommand\caption@startslc{%
  \begingroup
  \let\label\@gobble\let\@footnotetext\@gobble
  \def\stepcounter##1{\advance\csname c@##1\endcsname\@ne\relax}%
  \let\caption@hj\relax}
\newcommand\caption@endslc{%
  \endgroup}
\newcommand*\caption@startbox[1]{\vbox\bgroup\hsize#1}%
\newcommand*\caption@endbox{\egroup}
\newcommand\caption@@@make[2]{%
  \caption@ifempty{#2}{% changed v3.0e
    \let\caption@lsep\relax
    \let\caption@ifstrut\@secondoftwo % added v3.0e
  }%
  \def\caption@@par{%
    \parindent\captionparindent\hangindent\captionhangindent}%
  \@setpar{\@@par\caption@@par}\caption@@par
  \caption@hj\captionsize\captionfont
  \caption@fmt{\ifcaption@star\else{\captionlabelfont#1}\fi}%
              {\ifcaption@star\else{\captionlabelfont\caption@lsep}\fi}%
              {{\captiontextfont
                \caption@ifstrut{\vrule\@height\ht\strutbox\@width\z@}{}%
                \nobreak\hskip\z@skip
                #2%
                \caption@ifstrut{\@finalstrut\strutbox}{}%
                \par}}}
\newcommand\caption@ifempty[1]{%
  \def\caption@tempa{#1}%
  \def\caption@tempb{\ignorespaces}%
  \ifx\caption@tempa\caption@tempb
    \let\caption@tempa\@empty
  \fi
  \ifx\caption@tempa\@empty
    \expandafter\@firstofone
  \else
    \expandafter\@gobble
  \fi}
\endinput
%%
%% End of file `caption3.sty'.