Debian Codegraph @

texmf-dist/source/latex/caption/fallback/v2.1/caption2.dtx

raw
1 % \iffalse meta-comment
2 %
3 % This is file `caption2.dtx'.
4 %
5 % Copyright (C) 1994-2005 Axel Sommerfeldt ([email protected])
6 %
7 % --------------------------------------------------------------------------
8 %
9 % This work may be distributed and/or modified under the
10 % conditions of the LaTeX Project Public License, either version 1.3
11 % of this license or (at your option) any later version.
12 % The latest version of this license is in
13 % http://www.latex-project.org/lppl.txt
14 % and version 1.3 or later is part of all distributions of LaTeX
15 % version 2003/12/01 or later.
16 %
17 % This work has the LPPL maintenance status "maintained".
18 %
19 % This Current Maintainer of this work is Axel Sommerfeldt.
20 %
21 % This work consists of the files caption.ins, caption.dtx,
22 % caption2.dtx, caption.xml, and anleitung.tex and the derived files
23 % caption.sty, caption2.sty, caption3.sty, and manual.tex.
24 %
25 % \fi
26 % \CheckSum{843}
27 %
28 % \iffalse
29 %<*driver>
30 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
31 \documentclass{ltxdoc}
32 \setlength\parindent{0pt}
33 \setlength\parskip{\smallskipamount}
34 %
35 \ifx\pdfoutput\undefined\else
36 \ifcase\pdfoutput\else
37 \usepackage{mathptmx,courier}
38 \usepackage[scaled=0.90]{helvet}
39 \fi
40 \fi
41 %
42 \usepackage{caption2}[2004/04/16]
43 %
44 %<+driver>\OnlyDescription
45 %
46 \begin{document}
47 \DocInput{caption2.dtx}
48 \end{document}
49 %</driver>
50 % \fi
51 %
52 % \newcommand*{\purerm}[1]{{\upshape\mdseries\rmfamily #1}}
53 % \newcommand*{\puresf}[1]{{\upshape\mdseries\sffamily #1}}
54 % \newcommand*{\purett}[1]{{\upshape\mdseries\ttfamily #1}}
55 % \let\package\puresf\def\thispackage{\package{caption2}}
56 % \let\env\purett \let\opt\purett
57 %
58 % \GetFileInfo{caption2.sty}
59 % \title{The \thispackage\ package\thanks{This package has version number
60 % \fileversion, last revised \filedate.}}
61 % \author{Axel Sommerfeldt\\\texttt{[email protected]}}
62 % \date{2005/11/02}
63 % \maketitle
64 %
65 % \changes{v2.0}{ 9 Oct 95}{New experimental version: Many new commands and features}
66 % \changes{v2.0}{ 9 Oct 95}{Support of the longtable package added}
67 % \changes{v2.1}{20 Feb 02}{Revised: New commands and options}
68 % \changes{v2.1}{26 Feb 02}{Adapted to version 2.1 of the subfigure package}
69 % \changes{v2.1a}{12 Nov 03}{Some minor bug fixes and improved compatibility to v2.0}
70 % \changes{v2.1b}{16 Apr 04}{Some minor bug fixes and improved compatibility to v2.0}
71 % \changes{v2.1c}{10 May 04}{Some minor bug fixes and improved compatibility to v2.0}
72 % \changes{v2.1d}{ 3 Oct 05}{Some superfluous brackets removed; warning added}
73 %
74 % \providecommand\LaTeXcomp{The \LaTeX{} Companion}
75 %
76 % \section*{This package is obsolete!}
77 %
78 % The \package{caption2} package used to be an experimental side-version of
79 % the regular \package{caption} package. It was made public as beta test version
80 % without documentation in 1995 because of the demand for new features and
81 % adaptations to other packages like the \package{longtable} and
82 % \package{subfigure} package.
83 %
84 % Even in the next years I found no time to reintegrate some of the
85 % well-tried features into the regular \package{caption} package. So I
86 % decided to release a version $2.1$ of the \package{caption2} package in 2002
87 % instead, which included some minor bug fixes and adaptations to the new
88 % version $2.1$ of the \package{subfigure} package. Furthermore I started
89 % to write a documentation for this package, but unfortunately did not get
90 % very far with this\ldots
91 %
92 % In 2003 I finally found some (more) time, so a new regular release $3.0$
93 % of the \package{caption} package could be build with massive help from
94 % Frank Mittelbach\cite{A-W:GMS94} and Steven Cochran\cite{subfigure}.
95 % It was released in December 2003 and superseded the neglected
96 % \package{caption2} package.
97 %
98 % {\small (In parallel, Steven Cochran released the \package{subfig} package which
99 % superseded the \package{subfigure} package.)}
100 %
101 % So please don't use this package for new documents. It's old, it's obsolete
102 % and it starts to begin smell bad!
103 % Please ignore all hints in books or other documents which try to tell you
104 % that the \package{caption2} package should be used instead of the
105 % \package{caption} package -- these hints are outdated since December 2003.
106 %
107 % \section*{How to migrate to the regular \package{caption} package?}
108 %
109 % Usually replacing \package{caption2} by \package{caption} is sufficient
110 % because the \package{caption} package emulates most of the options and
111 % commands of the \package{caption2} package.
112 % If you get some errors or wired results afterwards, please take a closer
113 % look at the \package{caption} package documentation which will hopefully
114 % help you clearing these problems.
115 % If all this should fail you can write me an e-mail asking for help.
116 %
117 % \section*{What will happen to this package?}
118 %
119 % The \package{caption2} package is still some kind of supported, that means
120 % it will be part of future releases and bugs will still be fixed so existing
121 % documents using this package will still compile.
122 % But it will \emph{not} be enhanced in the future or adapted to future versions
123 % of foreign packages.
124 %
125 % This means migrating to the actual \package{caption} package should not be
126 % necessary for old documents.
127 %
128 % \StopEventually{}
129 %
130 % \DoNotIndex{\\,\_,\ ,\@@par}
131 % \DoNotIndex{\@classoptionslist,\@currext,\@currname}
132 % \DoNotIndex{\@ehc,\@ehd,\@empty,\@expandtwoargs}
133 % \DoNotIndex{\@for,\@firstofone,\@firstoftwo}
134 % \DoNotIndex{\@gobble,\@gobblefour,\@gobbletwo,\@hangfrom}
135 % \DoNotIndex{\@ifnextchar,\@ifstar,\@ifundefined,\@latex@error}
136 % \DoNotIndex{\@namedef,\@nameuse}
137 % \DoNotIndex{\@onlypreamble,\@parboxrestore,\@plus,\@ptionlist}
138 % \DoNotIndex{\@removeelement,\@restorepar,\@secondoftwo,\@setpar}
139 % \DoNotIndex{\@tempa,\@tempboxa,\@tempdima,\@tempb,\@tempc}
140 % \DoNotIndex{\@undefined,\@unprocessedoptions,\@unusedoptionlist}
141 % \DoNotIndex{\p@,\z@}
142 % \DoNotIndex{\active,\addtocounter,\addtolength,\advance}
143 % \DoNotIndex{\baselineskip,\begin,\begingroup,\bfseries,\bgroup,\box}
144 % \DoNotIndex{\catcode,\centering,\changes,\csname,\def,\divide,\do,\downarrow}
145 % \DoNotIndex{\edef,\egroup,\else,\empty,\end,\endcsname,\endgraf,\endgroup,\expandafter}
146 % \DoNotIndex{\fi,\footnotesize,\global}
147 % \DoNotIndex{\hangindent,\hbox,\hfil,\hsize,\hskip,\hspace,\hss}
148 % \DoNotIndex{\if,\ifcase,\ifdim,\ifnum,\ifodd,\ifvoid,\ifvmode}
149 % \DoNotIndex{\ifx,\ignorespaces,\itshape}
150 % \DoNotIndex{\Large,\large,\leavevmode,\leftmargini,\leftskip,\let,\linewidth}
151 % \DoNotIndex{\llap,\long,\m@ne,\margin,\mdseries,\message}
152 % \DoNotIndex{\newcommand,\newdimen,\newlength,\newline,\newif,\newsavebox}
153 % \DoNotIndex{\next,\nobreakspace,\noexpand,\noindent,\numberline}
154 % \DoNotIndex{\normalsize,\or,\par,\parbox,\parfillskip}
155 % \DoNotIndex{\parindent,\parskip,\prevdepth,\protect,\protected@edef,\providecommand}
156 % \DoNotIndex{\quad}
157 % \DoNotIndex{\raggedleft,\raggedright,\relax,\renewcommand,\RequirePackage}
158 % \DoNotIndex{\rightskip,\rmfamily}
159 % \DoNotIndex{\sbox,\scriptsize,\scshape,\setbox,\setlength,\sffamily,\slshape}
160 % \DoNotIndex{\small,\string,\space,\strut}
161 % \DoNotIndex{\textheight,\the,\toks@,\typeout,\ttfamily}
162 % \DoNotIndex{\undefined,\unvbox,\uparrow,\upshape,\usebox,\usepackage}
163 % \DoNotIndex{\vbox,\vsize,\vskip,\wd,\width,\z@skip}
164 % \DoNotIndex{\AtBeginDocument,\AtEndOfPackage,\CurrentOption,\DeclareOption}
165 % \DoNotIndex{\ExecuteOptions,\GenericWarning,\IfFileExists,\InputIfFileExists}
166 % \DoNotIndex{\NeedsTeXFormat,\MessageBreak}
167 % \DoNotIndex{\PackageError,\PackageInfo,\PackageWarning,\PackageWarningNoLine}
168 % \DoNotIndex{\ProcessOptions,\ProvidesPackage}
169 %
170 % \clearpage
171 %
172 % \section{The Implementation}
173 % \iffalse
174 %<*package>
175 % \fi
176 %
177 % \subsection{Identificaton}
178 %
179 % \begin{macrocode}
180 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
181 \ProvidesPackage{caption2}[2005/10/03 v2.1d Customising captions (AS)]
182 %\PackageWarning{caption2}{THIS PACKAGE IS OBSOLETE, PLEASE USE caption INSTEAD}
183 % \end{macrocode}
184 %
185 % \subsection{Preliminary declarations}
186 %
187 % \begin{macro}{\captionfont}
188 % \begin{macro}{\captionlabelfont}
189 % \cs{captionfont} and \cs{captionlabelfont} will hold the font specifications for the caption.
190 % \begin{macrocode}
191 \newcommand*\captionfont{}
192 \newcommand*\captionlabelfont{}
193 % \end{macrocode}
194 % \end{macro}
195 % \end{macro}
196 %
197 % \begin{macro}{\captionlabeldelim}
198 % \begin{macro}{\captionlabelsep}
199 % \cs{captionlabeldelim} \& \cs{captionlabelsep} will hold the iterim
200 % space between caption label and text.
201 % (\cs{captionlabeldelim} will be typeset within \cs{captionlabelfont},
202 % \cs{captionlabelsep} not.)
203 % \begin{macrocode}
204 \newcommand*\captionlabeldelim{}
205 \newcommand*\captionlabelsep{}
206 % \end{macrocode}
207 % \end{macro}
208 % \end{macro}
209 %
210 % \begin{macro}{\captionsize}
211 % The macro \cs{captionsize} is obsolete since v1.4 of the \textsf{caption} package,
212 % but we still support it to provide backward compatibility.
213 % \begin{macrocode}
214 \newcommand*\captionsize{}
215 % \end{macrocode}
216 % \end{macro}
217 %
218 % \begin{macro}{\captionmargin}
219 % \begin{macro}{\captionwidth}
220 % \begin{macro}{\ifcaptionwidth}
221 % Either \cs{captionmargin} (with specifies an extra margin) or \cs{captionwidth}
222 % (with specifies an explicit width) can be set, therefore we need the flag \cs{ifcaptionwidth}
223 % to determine with parameter we should pay attention to.
224 % \begin{macrocode}
225 \newdimen\captionmargin
226 \newdimen\captionwidth
227 \newif\ifcaptionwidth
228 % \end{macrocode}
229 % \end{macro}
230 % \end{macro}
231 % \end{macro}
232 %
233 % \begin{macro}{\captionindent}
234 % \cs{captionindent} will be used in caption style \texttt{indent} and specifies the indention
235 % after the first line.
236 % \begin{macrocode}
237 \newdimen\captionindent
238 % \end{macrocode}
239 % \end{macro}
240 %
241 % \begin{macro}{\ifcaptionlabel}
242 % \begin{macro}{\ifonelinecaptions}
243 % \begin{macro}{\ifignoreLTcapwidth}
244 % More flags. If \cs{ifcaptionlabel} is not set the caption label should be suppressed;
245 % we need this flag to support the \cs{caption*} command.
246 % If \cs{ifonelinecaptions} is set we support the \LaTeX\ base style 'one line captions',
247 % that means the caption will be typeset centered if it fits to one line.
248 % If \cs{ifignoreLTcapwidth} is set we ignore the \cs{LTcapwidth} of \textsf{longtable}.
249 % \changes{v2.1}{20 Feb 02}{New ifs \cs{ifcaptionlabel} and \cs{ifignoreLTcapwidth}}
250 % \begin{macrocode}
251 \newif\ifcaptionlabel\captionlabeltrue
252 \newif\ifonelinecaptions
253 \newif\ifignoreLTcapwidth
254 % \end{macrocode}
255 % \end{macro}
256 % \end{macro}
257 % \end{macro}
258 %
259 % \begin{macro}{\setcaptionmargin}
260 % \begin{macro}{\setcaptionwidth}
261 % User-friendly commands to set the caption margin resp.\ width.
262 % Note that they additionally set the \cs{ifcaptionwidth} flag.
263 % \begin{macrocode}
264 \newcommand*\setcaptionmargin{%
265 \captionwidthfalse
266 \setlength\captionmargin}
267 \newcommand*\setcaptionwidth{%
268 \captionwidthtrue
269 \setlength\captionwidth}
270 % \end{macrocode}
271 % \end{macro}
272 % \end{macro}
273 %
274 % \begin{macro}{\normalcaptionparams}
275 % \cs{normalcaptionparams} resets all caption related parameters to it's normal default values.
276 % \cs{captionfont} will be set to \cs{captionsize} so setting the obsolete \cs{captionsize} will still work.
277 % Same story with \cs{captiondelim} and the obsolete \cs{captionlabeldelim}.
278 % \changes{v2.1}{29 Jan 02}{New command \cs{normalcaptionparams}}
279 % \begin{macrocode}
280 \newcommand*\normalcaptionparams{%
281 \let\captionsize\@empty
282 \renewcommand*\captionfont{\captionsize}%
283 \let\captionlabelfont\@empty
284 \renewcommand*\captionlabeldelim{:}%
285 \renewcommand*\captionlabelsep{\space}%
286 \setcaptionmargin\z@\setlength\captionindent\z@
287 \onelinecaptionstrue}
288 % \end{macrocode}
289 % \end{macro}
290 %
291 % \begin{macro}{\caption@eh}
292 % Some commands will produce an error message, use this as help text.
293 % \begin{macrocode}
294 \newcommand*\caption@eh{%
295 If you do not understand this error, please take a closer look\MessageBreak
296 at the documentation of the `caption2' package.\MessageBreak
297 \@ehc}
298 % \end{macrocode}
299 % \end{macro}
300 %
301 % \begin{macro}{\defcaptionstyle}
302 % \begin{macro}{\newcaptionstyle}
303 % \begin{macro}{\renewcaptionstyle}
304 % These macros will define a new caption style. \cs{newcaptionstyle} and \cs{renewcaptionstyle}
305 % will additionally check if the caption style already exists or not.
306 % \begin{macrocode}
307 \newcommand*\defcaptionstyle[1]{%
308 \@namedef{caption@@#1}}
309 %
310 \newcommand*\newcaptionstyle[1]{%
311 \expandafter\ifx\csname caption@@#1\endcsname\relax
312 \expandafter\defcaptionstyle
313 \else
314 \PackageError{caption2}{Caption style `#1' already defined}{\caption@eh}%
315 \expandafter\@gobbletwo
316 \fi
317 {#1}}
318 %
319 \newcommand*\renewcaptionstyle[1]{%
320 \expandafter\ifx\csname caption@@#1\endcsname\relax
321 \PackageError{caption2}{Caption style `#1' undefined}{\caption@eh}%
322 \expandafter\@gobbletwo
323 \else
324 \expandafter\defcaptionstyle
325 \fi
326 {#1}}
327 % \end{macrocode}
328 % \end{macro}
329 % \end{macro}
330 % \end{macro}
331 %
332 % \begin{macro}{\dummycaptionstyle}
333 % This macro will also define a new caption style, but a one which is based on the
334 % actual set caption style. Therefore you can't set a caption style made with this
335 % command with \cs{captionstyle} -- we check this to avoid an endless recursion.
336 % \begin{macrocode}
337 \newcommand*\dummycaptionstyle[2]{%
338 \defcaptionstyle{#1}{%
339 \expandafter\ifx\csname caption@@\caption@style\expandafter\endcsname%
340 \csname caption@@#1\endcsname
341 \PackageError{caption2}{You can't use the caption style `#1' directy}{%
342 The caption style `#1' is only a dummy and does not really exists.%
343 \MessageBreak You have to redefine it (with \protect\renewcaptionstyle)
344 before you can select\MessageBreak it with \protect\captionstyle.
345 \space\caption@eh}%
346 \else
347 #2\usecaptionstyle\caption@style
348 \fi}}
349 % \end{macrocode}
350 % \end{macro}
351 %
352 % \begin{macro}{\captionstyle}
353 % \cs{captionstyle} sets the actual caption style. It includes a check if the given caption
354 % style is defined or not.
355 % \begin{macrocode}
356 \newcommand*\captionstyle[1]{%
357 \expandafter\ifx\csname caption@@#1\endcsname\relax
358 \PackageError{caption2}{Undefined caption style `#1'}{\caption@eh}%
359 \else
360 \def\caption@style{#1}%
361 \fi}
362 % \end{macrocode}
363 % \end{macro}
364 %
365 % \begin{macro}{style `normal'}
366 % \begin{macro}{style `center'}
367 % \begin{macro}{style `centerlast'}
368 % \begin{macro}{style `flushleft'}
369 % \begin{macro}{style `flushright'}
370 % \begin{macro}{style `hang'}
371 % \begin{macro}{style `indent'}
372 % The predefined caption styles `normal', `center', `flushleft', `flushright', `centerlast',
373 % `hang', `hang+X', and `indent'. Because they are quite similar they all are based on the macro
374 % \cs{caption@make}.
375 % \begin{macrocode}
376 \newcaptionstyle{normal}{\caption@make{normal}}
377 \newcaptionstyle{center}{\caption@make{center}}
378 \newcaptionstyle{centerlast}{\caption@make{centerlast}}
379 \newcaptionstyle{flushleft}{\caption@make{flushleft}}
380 \newcaptionstyle{flushright}{\caption@make{flushright}}
381 \newcaptionstyle{hang}{\caption@make{hang}}
382 \newcaptionstyle{hang+center}{\caption@make{hang@center}}
383 \newcaptionstyle{hang+centerlast}{\caption@make{hang@centerlast}}
384 \newcaptionstyle{hang+flushleft}{\caption@make{hang@flushleft}}
385 \newcaptionstyle{indent}{\caption@make{indent}}
386 % \end{macrocode}
387 % \end{macro}
388 % \end{macro}
389 % \end{macro}
390 % \end{macro}
391 % \end{macro}
392 % \end{macro}
393 % \end{macro}
394 %
395 % \begin{macro}{\caption@makecaption}
396 % Our predefined caption styles. \cs{caption@makecaption} takes the style
397 % name as parameter, it does the common stuff and calls a macro
398 % (build out of the style name) to do the uncommon stuff if neccessary.
399 % \changes{v2.1}{26 Feb 02}{Renamed from \cs{caption@make} to \cs{caption@makecaption}}
400 % \changes{v2.1b}{16 Apr 04}{We offer and use \cs{caption@make}, again}
401 % \changes{v2.1c}{10 May 04}{Bugfix: Extra \cs{par} added}
402 % \begin{macrocode}
403 \newcommand*\caption@makecaption[1]{%
404 \usecaptionmargin
405 %
406 \ifcaptionlabel
407 \def\caption@label{%
408 {\captionlabelfont\captionlabel\captionlabeldelim}\captionlabelsep}%
409 \else
410 \let\caption@label\@empty
411 \fi
412 %
413 \captionfont
414 \onelinecaption
415 {\caption@label\captiontext}%
416 {\parbox[b]\captionlinewidth{\strut\@nameuse{caption@@@#1}\par}\par}}
417 \newcommand*\caption@make{\caption@makecaption}
418 % \end{macrocode}
419 % \end{macro}
420 %
421 % \changes{v2.1}{26 Feb 02}{Removed all extra parboxes from caption styles}
422 % \changes{v2.1a}{12 Nov 03}{\ldots and put the parbox into \cs{caption@makecaption} instead}
423 %
424 % \begin{macro}{\caption@@@normal}
425 % The `normal' caption style. Just typeset caption (label \& text) as paragraph.
426 % \begin{macrocode}
427 \newcommand*\caption@@@normal{%
428 \caption@label\captiontext}
429 % \end{macrocode}
430 % \end{macro}
431 %
432 % \begin{macro}{\caption@@@center}
433 % The `center' caption style. Typeset the caption centered within a parbox.
434 % \begin{macrocode}
435 \newcommand*\caption@@@center{%
436 \centering\caption@label\captiontext}%
437 % \end{macrocode}
438 % \end{macro}
439 %
440 % \begin{macro}{\caption@@@centerlast}
441 % The `centerlast' caption style.
442 % The idea how to do this was taken from Br\"uggemann-Klein\cite{Anne},
443 % it is also mentioned in Kopka\cite[p227]{Kopka-E}.
444 % \begin{macrocode}
445 \newcommand*\caption@centerlast{%
446 \advance\leftskip by 0pt plus 1fil%
447 \advance\rightskip by 0pt plus -1fil%
448 \parfillskip0pt plus 2fil\relax}
449 %
450 \newcommand*\caption@@@centerlast{%
451 \caption@centerlast\caption@label\captiontext}
452 % \end{macrocode}
453 % \end{macro}
454 %
455 % \begin{macro}{\caption@@@flushleft}
456 % The `flushleft' caption style. Typeset the caption raggedright within a parbox.
457 % \begin{macrocode}
458 \newcommand*\caption@@@flushleft{%
459 \raggedright\caption@label\captiontext}%
460 % \end{macrocode}
461 % \end{macro}
462 %
463 % \begin{macro}{\caption@@@flushright}
464 % The `flushright' caption style. Typeset the caption raggedleft within a parbox.
465 % \begin{macrocode}
466 \newcommand*\caption@@@flushright{%
467 \raggedleft\caption@label\captiontext}%
468 % \end{macrocode}
469 % \end{macro}
470 %
471 % \begin{macro}{\caption@@@hang}
472 % \begin{macro}{\caption@hangplus}
473 % The `hang' caption style.
474 % This code was taken from \LaTeXcomp\cite[p155]{A-W:GMS94} and modified.
475 % \begin{macrocode}
476 \newcommand*\caption@@@hang{%
477 \sbox\@tempboxa{\caption@label}%
478 \hangindent\wd\@tempboxa\noindent
479 \usebox\@tempboxa\caption@hangplus\captiontext}
480 %
481 \newcommand*\caption@hangplus{}
482 % \end{macrocode}
483 % \end{macro}
484 % \end{macro}
485 %
486 % \begin{macro}{\caption@@@hang@center}
487 % The `hang+flushleft' caption style.
488 % \begin{macrocode}
489 \newcommand*\caption@@@hang@center{%
490 \let\caption@hangplus\centering\caption@@@hang}
491 % \end{macrocode}
492 % \end{macro}
493 %
494 % \begin{macro}{\caption@@@hang@centerlast}
495 % The `hang+flushleft' caption style.
496 % \begin{macrocode}
497 \newcommand*\caption@@@hang@centerlast{%
498 \let\caption@hangplus\caption@centerlast\caption@@@hang}
499 % \end{macrocode}
500 % \end{macro}
501 %
502 % \begin{macro}{\caption@@@hang@flushleft}
503 % The `hang+flushleft' caption style.
504 % \begin{macrocode}
505 \newcommand*\caption@@@hang@flushleft{%
506 \let\caption@hangplus\raggedright\caption@@@hang}
507 % \end{macrocode}
508 % \end{macro}
509 %
510 % \begin{macro}{\caption@@@indent}
511 % The `indent' caption style. Is is quite like the `hang' style but the
512 % indention is given as \cs{captionindent}.
513 % \begin{macrocode}
514 \newcommand*\caption@@@indent{%
515 \hangindent\captionindent\noindent
516 \caption@label\captiontext}
517 % \end{macrocode}
518 % \end{macro}
519 %
520 % \subsection{Options}
521 %
522 % \begin{macro}{normal}
523 % \begin{macro}{center}
524 % \begin{macro}{centerlast,anne}
525 % \begin{macro}{flushleft}
526 % \begin{macro}{flushright}
527 % \begin{macro}{hang,isu}
528 % \begin{macro}{indent}
529 % These options will set the caption style.
530 % (`normal' is the default one.)
531 %
532 % The options `anne' and `isu' are for
533 % backward compatibility only.
534 % \begin{macrocode}
535 \DeclareOption{normal}{\captionstyle{normal}}
536 \DeclareOption{center}{\captionstyle{center}}
537 \DeclareOption{centerlast}{\captionstyle{centerlast}}
538 \DeclareOption{flushleft}{\captionstyle{flushleft}}
539 \DeclareOption{flushright}{\captionstyle{flushright}}
540 \DeclareOption{anne}{\ExecuteOptions{centerlast}}
541 \DeclareOption{hang}{\captionstyle{hang}}
542 \DeclareOption{hang+center}{\captionstyle{hang+center}}
543 \DeclareOption{hang+centerlast}{\captionstyle{hang+centerlast}}
544 \DeclareOption{hang+flushleft}{\captionstyle{hang+flushleft}}
545 \DeclareOption{isu}{\ExecuteOptions{hang}}
546 \DeclareOption{indent}{\captionstyle{indent}}
547 % \end{macrocode}
548 % \end{macro}
549 % \end{macro}
550 % \end{macro}
551 % \end{macro}
552 % \end{macro}
553 % \end{macro}
554 % \end{macro}
555 %
556 % \begin{macro}{scriptsize}
557 % \begin{macro}{footnotesize}
558 % \begin{macro}{small}
559 % \begin{macro}{normalsize}
560 % \begin{macro}{large,Large}
561 % These options will set the caption size. We use \cs{g@addto@macro} so more that one
562 % option can be set.
563 % \begin{macrocode}
564 \DeclareOption{scriptsize}{\g@addto@macro\captionsize\scriptsize}
565 \DeclareOption{footnotesize}{\g@addto@macro\captionsize\footnotesize}
566 \DeclareOption{small}{\g@addto@macro\captionsize\small}
567 \DeclareOption{normalsize}{\g@addto@macro\captionsize\normalsize}
568 \DeclareOption{large}{\g@addto@macro\captionsize\large}
569 \DeclareOption{Large}{\g@addto@macro\captionsize\Large}
570 % \end{macrocode}
571 % \end{macro}
572 % \end{macro}
573 % \end{macro}
574 % \end{macro}
575 % \end{macro}
576 %
577 % \begin{macro}{up,it,sl,sc}
578 % \begin{macro}{md,bf}
579 % \begin{macro}{rm,sf,tt}
580 % These options will set the caption label.
581 % \begin{macrocode}
582 \DeclareOption{up}{\g@addto@macro\captionlabelfont\upshape}
583 \DeclareOption{it}{\g@addto@macro\captionlabelfont\itshape}
584 \DeclareOption{sl}{\g@addto@macro\captionlabelfont\slshape}
585 \DeclareOption{sc}{\g@addto@macro\captionlabelfont\scshape}
586 \DeclareOption{md}{\g@addto@macro\captionlabelfont\mdseries}
587 \DeclareOption{bf}{\g@addto@macro\captionlabelfont\bfseries}
588 \DeclareOption{rm}{\g@addto@macro\captionlabelfont\rmfamily}
589 \DeclareOption{sf}{\g@addto@macro\captionlabelfont\sffamily}
590 \DeclareOption{tt}{\g@addto@macro\captionlabelfont\ttfamily}
591 % \end{macrocode}
592 % \end{macro}
593 % \end{macro}
594 % \end{macro}
595 %
596 % \begin{macro}{oneline}
597 % \begin{macro}{nooneline}
598 % These options will set the `oneline' flag.
599 % (`oneline' is the default.)
600 % \begin{macrocode}
601 \DeclareOption{oneline}{\onelinecaptionstrue}
602 \DeclareOption{nooneline}{\onelinecaptionsfalse}
603 % \end{macrocode}
604 % \end{macro}
605 % \end{macro}
606 %
607 % \begin{macro}{\caption@package}
608 % A helper macro, a value of 1 within parameter \#2 will activate the support
609 % of the package given in parameter \#1, a value of 0 will deactivate it.
610 % \begin{macrocode}
611 \newcommand*\caption@package[1]{\@namedef{caption@pkt@#1}}
612 % \end{macrocode}
613 % \end{macro}
614 %
615 % \begin{macro}{float}
616 % \begin{macro}{longtable}
617 % \begin{macro}{subfigure}
618 % \changes{v2.1}{19 Feb 02}{New options for interaction with other packages}
619 % These options will enable or suppress the support of the packages
620 % \textsf{float}, \textsf{longtable}, and \textsf{subfigure}.
621 % \begin{macrocode}
622 \DeclareOption{float}{\caption@twozerofalse\caption@package{float}{1}}
623 \DeclareOption{longtable}{\caption@twozerofalse\caption@package{longtable}{1}}
624 \DeclareOption{subfigure}{\caption@twozerofalse\caption@package{subfigure}{1}}
625 % \end{macrocode}
626 % \end{macro}
627 % \end{macro}
628 % \end{macro}
629 %
630 % \begin{macro}{none}
631 % \begin{macro}{all}
632 % These options will enable or suppress the support of all the above packages.
633 % \begin{macrocode}
634 \DeclareOption{none}{\caption@twozerofalse
635 \caption@package{float}{0}\caption@package{longtable}{0}%
636 \caption@package{subfigure}{0}}
637 \DeclareOption{all}{\ExecuteOptions{float,longtable,subfigure}}
638 % \end{macrocode}
639 % \end{macro}
640 % \end{macro}
641 %
642 % \begin{macro}{ruled}
643 % \begin{macro}{boxed}
644 % The option `ruled' introduced in \textsf{caption} v1.2 is obsolete now, but
645 % we will still support it. The option `boxed' was introduced in version 2.0
646 % and is obsolete now, too.
647 % \begin{macrocode}
648 \newif\ifcaption@ruled
649 \DeclareOption{ruled}{\caption@ruledtrue}
650 \DeclareOption{boxed}{}
651 % \end{macrocode}
652 % \end{macro}
653 % \end{macro}
654 %
655 % \begin{macro}{ignoreLTcapwidth}
656 % This option will make the caption code ignore the setting of \cs{LTcapwidth}
657 % and use the setting of \cs{setcaptionmargin} or \cs{setcaptionwidth} instead.
658 % \begin{macrocode}
659 \DeclareOption{ignoreLTcapwidth}{\ignoreLTcapwidthtrue}
660 % \end{macrocode}
661 % \end{macro}
662 %
663 % \begin{macro}{debug}
664 % This option will put additional debug information in the log file.
665 % \begin{macrocode}
666 \DeclareOption{debug}{\caption@debugtrue}
667 % \end{macrocode}
668 % \end{macro}
669 %
670 % That's it! Now set the default values and start processing the options.
671 % (If \cs{caption@twozero} is set to true (default) we will emulate the package
672 % load algorithm of \textsf{caption} v2.0: If the package is already loaded
673 % patch it, otherwise do nothing.)
674 % \changes{v2.1}{19 Feb 02}{\cs{ProcessOptions} changed to \cs{ProcessOptions*}}
675 % \begin{macrocode}
676 \newif\ifcaption@debug
677 \newif\ifcaption@twozero
678 \normalcaptionparams
679 \ExecuteOptions{none,normal}
680 \caption@twozerotrue
681 \ProcessOptions*
682 \ifcaption@twozero
683 \PackageInfo{caption2}{Running in caption2 v2.0 compatibility mode}
684 \fi
685 % \end{macrocode}
686 %
687 % \subsection{More declarations}
688 %
689 % \begin{macro}{\captionof}
690 % \begin{macro}{\captionof*}
691 % \cs{captionof} resp.\ \cs{captionof*} will just set \cs{@captype} and do the normal
692 % \cs{caption} resp.\ \cs{caption*}, so we can also typeset captions outside floating
693 % environments.
694 % \changes{v2.1}{19 Feb 02}{New commands \cs{captionof} and \cs{captionof*}}
695 % \begin{macrocode}
696 \def\captionof{\@ifstar{\caption@of{\caption*}}{\caption@of\caption}}
697 \newcommand*\caption@of[2]{\def\@captype{#2}#1}
698 % \end{macrocode}
699 % \end{macro}
700 % \end{macro}
701 %
702 % \begin{macro}{\abovecaptionskip}
703 % \begin{macro}{\belowcaptionskip}
704 % Not all document classes define \cs{abovecaptionskip} and \cs{belowcaptionskip}
705 % (like \textsf{ucthesis}), so we do it here if not already done.
706 % \changes{v2.1}{19 Feb 02}{\cs{abovecaptionskip} and \cs{belowcaptionskip} will be defined if neccessary}
707 % \begin{macrocode}
708 \@ifundefined{abovecaptionskip}{%
709 \newlength\abovecaptionskip\setlength\abovecaptionskip{10\p@}}{}
710 \@ifundefined{belowcaptionskip}{%
711 \newlength\belowcaptionskip\setlength\belowcaptionskip{0\p@}}{}
712 % \end{macrocode}
713 % \end{macro}
714 % \end{macro}
715 %
716 % \begin{macro}{\captionlinewidth}
717 % \changes{v2.1}{26 Feb 02}{Renamed from \cs{realcaptionwidth} to \cs{captionlinewidth}}
718 % \changes{v2.1a}{12 Nov 03}{We offer \cs{realcaptionwidth}, again}
719 % \begin{macro}{\captionlabel}
720 % \begin{macro}{\captiontext}
721 % These values are only set and used within the caption code itself.
722 % \cs{captionlinewidth} will be set to the given vertical space for the caption,
723 % normally this is \cs{linewidth}. (This value was called \cs{realcaptionwidth}
724 % within \thispackage\ \mbox{2.0}, so we will offer this, too.)
725 %
726 % \cs{captionlabel} and \cs{captiontext} will be set to the caption label
727 % resp.\ the caption text.
728 % (Because \cs{captionlabel} and \cs{captiontext} will be locally defined with
729 % \cs{def} we do not need to define them here.)
730 % \begin{macrocode}
731 \newdimen\captionlinewidth
732 \newdimen\realcaptionwidth
733 % \end{macrocode}
734 % \end{macro}
735 % \end{macro}
736 % \end{macro}
737 %
738 % \begin{macro}{\usecaptionmargin}
739 % A helper macro for caption style authors:
740 % It calculates \cs{leftskip} and \cs{rightskip} out of
741 % \cs{captionlinewidth} and \cs{captionmargin} resp.\ \cs{captionwidth}.
742 % Also \cs{captionlinewidth} will be corrected to the appropriate value.
743 % \begin{macrocode}
744 \newcommand*\usecaptionmargin{%
745 \ifcaptionwidth
746 \leftskip\captionlinewidth
747 \advance\leftskip by -\captionwidth
748 \divide\leftskip by 2
749 \rightskip\leftskip
750 \captionlinewidth\captionwidth
751 \else
752 \leftskip\captionmargin
753 \rightskip\captionmargin
754 \advance\captionlinewidth by -2\captionmargin
755 \fi
756 \realcaptionwidth\captionlinewidth}
757 % \end{macrocode}
758 % \end{macro}
759 %
760 % \begin{macro}{\onelinecaption}
761 % This macro definition helps setting captions the \LaTeX\ base classes way:
762 % If \cs{ifonelinecaptions} is set and the 1st argument fits within \cs{captionlinewidth},
763 % we typeset it centered -- otherway we typeset the 2nd argument.
764 % (We use the savebox \cs{@tempboxa} as helper for this.)
765 % \begin{macrocode}
766 \newcommand\onelinecaption[1]{%
767 \let\next\@firstofone
768 \ifonelinecaptions
769 \sbox\@tempboxa{#1}%
770 \ifdim\wd\@tempboxa >\captionlinewidth
771 \else
772 \def\next{{\centering\usebox\@tempboxa\par}\@gobble}%
773 \fi
774 \fi\next}
775 % \end{macrocode}
776 % \end{macro}
777 %
778 % \begin{macro}{\usecaptionstyle}
779 % First we check if we are inside a caption -- if \cs{captiontext} is undefined we are not.
780 % If we are we call the appropriate caption definition.
781 %
782 % \changes{v2.1b}{16 Apr 04}{Missing percent added (and extra space removed)}
783 % \begin{macrocode}
784 \newcommand*\usecaptionstyle[1]{%
785 \@ifundefined{captiontext}{%
786 \PackageError{caption2}{You can't use \protect#1
787 in normal text}{The usage of \protect#1 is only
788 allowed inside code declared with\MessageBreak \protect\defcaptionstyle,
789 \protect\newcaptionstyle \space or \protect\renewcaptionstyle.
790 \space\caption@eh}
791 }{%
792 \@ifundefined{caption@@#1}%
793 {\PackageError{caption2}{Caption style `#1' undefined}{\caption@eh}}%
794 {\@nameuse{caption@@#1}}%
795 }}
796 % \end{macrocode}
797 % \end{macro}
798 %
799 % \begin{macro}{\@makecaption}
800 % This is the heart of the \thispackage\ package -- the redefinition of the
801 % core caption code. It was taken from the \LaTeXe\ standard classes and modified.
802 % It's very easy -- apart from using \cs{abovecaptionskip} and \cs{belowcaptionskip}
803 % we just set \cs{captionlinewidth}, \cs{captionlabel} and \cs{captiontext}
804 % to its appropriate values and using the code of the actual caption style via
805 % \cs{usecaptionstyle}.
806 % \begin{macrocode}
807 \renewcommand\@makecaption[2]{%
808 \vskip\abovecaptionskip
809 \captionlinewidth\hsize
810 \realcaptionwidth\hsize
811 \def\captionlabel{#1}%
812 \def\captiontext{#2}%
813 \usecaptionstyle\caption@style
814 \vskip\belowcaptionskip}
815 % \end{macrocode}
816 % \end{macro}
817 %
818 % \subsection{Support of other packages}
819 %
820 % \begin{macro}{\caption@package}
821 % This macro will execute the code needed to support the package
822 % named within argument \#1. The parameter \#2 is the command
823 % which shows if the package is loaded -- it is defined, it is
824 % already loaded, otherwise not. The parameter \#3 contains code
825 % which will be executed if no support is required -- this is for
826 % cleanup purposes. The final parameter \#4 contains the code itself.
827 % \changes{v2.1c}{9 May 04}{Compatibility warning removed}
828 % \begin{macrocode}
829 \renewcommand*\caption@package[3]{%
830 \if1\@nameuse{caption@pkt@#1}%
831 \@ifundefined{#2}%
832 {\let\next\AtBeginDocument}%
833 {\let\next\@firstofone}%
834 \else\ifcaption@twozero
835 \@ifundefined{#2}%
836 {#3\let\next\@gobble}%
837 {\let\next\@firstofone}%
838 \else
839 #3\let\next\@gobble
840 \fi\fi
841 \expandafter\let\csname caption@pkt@#1\endcsname\undefined
842 \ifcaption@debug
843 \ifx\next\@gobble\PackageInfo{caption2}{#1 => gobble}%
844 \else\ifx\next\@firstofone\PackageInfo{caption2}{#1 => firstofone}%
845 \else\ifx\next\AtBeginDocument\PackageInfo{caption2}{#1 => AtBeginDocument}%
846 \fi\fi\fi
847 \fi
848 \next}
849 % \end{macrocode}
850 % \end{macro}
851 %
852 % \subsubsection{Support of the \puresf{float} package}
853 %
854 % \begin{macrocode}
855 \caption@package{float}{floatc@plain}{}{%
856 \ifx\floatc@plain\relax
857 \PackageWarning{caption2}{%
858 Option `float' was set but there is no float package loaded}
859 \else
860 \PackageInfo{caption2}{float package v1.2 (or newer) detected}
861 % \end{macrocode}
862 %
863 % \begin{macro}{\caption@floatc}
864 % First we define a helper macro to typeset the caption via \cs{usecaptionstyle},
865 % the 1st parameter is the caption style name,
866 % the 2nd and 3rd are the caption label and text.
867 %
868 % \textsf{caption2} has the goal not to modify the output just by
869 % loading it (without options), therefore we have to be tricky here to
870 % support \cs{@fs@cfont} which is in fact the same as our \cs{captionlabelfont}.
871 % So we test if a \cs{captionlabelfont} has been set by the user -- if not
872 % \cs{@fs@cfont} will be used, otherwise \cs{captionlabelfont}.
873 %
874 % \changes{v2.1b}{19 Mar 04}{\cs{realcaptionwidth}$=$\cs{hsize} was missing here}
875 % \begin{macrocode}
876 \newcommand\caption@floatc[3]{%
877 \ifx\captionlabelfont\@empty
878 \let\captionlabelfont\@fs@cfont
879 \fi
880 \captionlinewidth\hsize
881 \realcaptionwidth\hsize
882 \def\captionlabel{#2}%
883 \def\captiontext{#3}%
884 \usecaptionstyle{#1}}
885 % \end{macrocode}
886 % \end{macro}
887 %
888 % \begin{macro}{\floatc@plain}
889 % Now we can redefine the caption code of the \textsf{float} package.
890 % Here we redefine \cs{floatc@plain} to use our caption code, so
891 % \texttt{plain} and \texttt{boxed} float types will use the actual
892 % caption style set by the user.
893 % \begin{macrocode}
894 \renewcommand*\floatc@plain{\caption@floatc{\caption@style}}
895 % \end{macrocode}
896 % \end{macro}
897 %
898 % \begin{macro}{\floatc@ruled}
899 % The support of the \texttt{ruled} float type is a little
900 % more complex. First we define a caption style `ruled' so the end-user
901 % can change this caption style afterwards. If the (obsolete) option
902 % `ruled' is set, we define it in a \textsf{caption} v1.x compatible way,
903 % otherwise we define it in a \textsf{float} compatible way.
904 %
905 % Then we redefine \cs{floatc@ruled} so the caption style `ruled' will
906 % be used.
907 % \begin{macrocode}
908 \ifcaption@ruled
909 \dummycaptionstyle{ruled}{\onelinecaptionsfalse\setcaptionmargin{\z@}}%
910 \else
911 \newcaptionstyle{ruled}{%
912 \ifcaptionlabel
913 {\@fs@cfont\captionlabel}\space%
914 \fi\captiontext\par}%
915 \fi
916 %
917 \renewcommand*\floatc@ruled{\caption@floatc{ruled}}
918 % \end{macrocode}
919 % \end{macro}
920 %
921 % \begin{macro}{\caption@of}
922 % Typesetting captions outside floats is not so easy with redefined floats,
923 % because
924 % \begin{itemize}
925 % \item The caption code of the \textsf{float} package needs not only
926 % \cs{@captype} defined, but \cs{@fs@capt} (the command which will typeset the
927 % caption itself) either.
928 % \item The caption is only saved within a \cs{vbox}, so the \textsf{float}
929 % package can typeset the caption later at it's float style specific place
930 % (that means at top or at the bottom of the float).
931 % \end{itemize}
932 %
933 % Here is the new code: First we check if it's a restyled float by checking if
934 % \cs{fst@<floattype>} is defined. If yes, we use this command (it will define
935 % \cs{@fs@capt}).
936 % Then we execute \cs{@float@setevery}, if it exists (that means we are
937 % dealing with the \textsf{float} package 1.3 or newer here).
938 % Now comes the basic trick:
939 % We redefine the caption typesetting command \cs{@fs@capt}, so it will close
940 % the \cs{vbox}, typeset the caption outside the vbox and finally start the
941 % group again so the original \cs{@fs@capt} is happy with closing the group.
942 %
943 % \begin{macrocode}
944 \renewcommand*\caption@of[2]{\def\@captype{#2}%
945 \@ifundefined{fst@#2}{}{%
946 \@nameuse{fst@#2}%
947 \@ifundefined{@float@setevery}{}{\@float@setevery{#2}}%
948 \let\caption@fs@capt\@fs@capt
949 \let\@fs@capt\caption@of@float}%
950 #1}
951 % \end{macrocode}
952 %
953 % \begin{macrocode}
954 \newcommand\caption@of@float[2]{\egroup
955 \vskip\abovecaptionskip
956 \normalsize\caption@fs@capt{#1}{#2}%
957 \vskip\belowcaptionskip
958 \bgroup}%
959 % \end{macrocode}
960 % \end{macro}
961 %
962 % \begin{macrocode}
963 \fi}
964 % \end{macrocode}
965 %
966 % \subsubsection{Support of the \puresf{longtable} package}
967 %
968 % \begin{macrocode}
969 \caption@package{longtable}{LT@makecaption}{}{%
970 \ifx\LT@makecaption\relax
971 \PackageWarning{caption2}{%
972 Option `longtable' was set but there is no longtable package loaded}
973 \else
974 \PackageInfo{caption2}{longtable package v3.15 (or newer) detected}
975 % \end{macrocode}
976 %
977 % \begin{macro}{\LT@makecaption}
978 % David Carlisle was so kind to introduce a macro called
979 % \cs{LT@makecaption} in version 3.15 of the \textsf{longtable}
980 % package which typeset the caption and can be easily redefined.
981 %
982 % This is the original definition:
983 % \begin{quote}
984 % |\def\LT@makecaption#1#2#3{%|\\
985 % | \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%|\\
986 % | |$\langle$\textit{typeset} |#1{#2: }#3| \textit{as caption}$\rangle$\\
987 % | \endgraf\vskip\baselineskip}%|\\
988 % | \hss}}}|
989 % \end{quote}
990 %
991 % So we do here:
992 % First we define a new (dummy) caption style `longtable',
993 % than we redefine \cs{LT@makecaption} so this style will be used.
994 % (Remember: |#1| is |\@gobble| in star form of |\caption|,
995 % and |\@firstofone| otherwise.)
996 % \begin{macrocode}
997 \dummycaptionstyle{longtable}{}
998 %
999 \renewcommand\LT@makecaption[3]{%
1000 \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\hsize{%
1001 \ifignoreLTcapwidth
1002 \else
1003 \setcaptionwidth\LTcapwidth
1004 \fi
1005 \captionlinewidth\hsize
1006 \realcaptionwidth\hsize
1007 \captionlabelfalse#1\captionlabeltrue
1008 \def\captionlabel{#2}%
1009 \def\captiontext{#3}%
1010 \usecaptionstyle{longtable}%
1011 \endgraf\vskip\baselineskip}%
1012 \hss}}}
1013 % \end{macrocode}
1014 % \end{macro}
1015 %
1016 % \begin{macrocode}
1017 \fi}
1018 % \end{macrocode}
1019 %
1020 % \subsubsection{Support of the \puresf{subfigure} package}
1021 %
1022 % Some of the following code will not work within \cs{if},
1023 % because of the (yet) undefined \cs{if}\textit{xxx}s. So we simply define
1024 % the critical code within the helper commands \cs{setsubcapstyle}
1025 % and \cs{caption@makesubcaption} already here.
1026 %
1027 % \begin{macro}{\setsubcapstyle}
1028 % This sets the subcaptionstyle to a appropriate value.
1029 %
1030 % If \cs{ifsubcapraggedright} is undefined (it was introduced
1031 % into v2.1 of the \textsf{subfigure} package) we define it first.
1032 % \begin{macrocode}
1033 \newcommand*\setsubcapstyle{%
1034 \@ifundefined{subcapraggedrightfalse}{%
1035 \newif\ifsubcapraggedright}{}%
1036 \ifsubcaphang
1037 \ifsubcapcenter
1038 \subcapstyle{hang+center}%
1039 \else\ifsubcapcenterlast
1040 \subcapstyle{hang+centerlast}%
1041 \else\ifsubcapraggedright
1042 \subcapstyle{hang+flushleft}%
1043 \else
1044 \subcapstyle{hang}%
1045 \fi\fi\fi
1046 \else\ifsubcapcenter
1047 \subcapstyle{center}%
1048 \else\ifsubcapcenterlast
1049 \subcapstyle{centerlast}%
1050 \else\ifsubcapraggedright
1051 \subcapstyle{flushleft}%
1052 \else
1053 \subcapstyle{normal}%
1054 \fi\fi\fi\fi}
1055 % \end{macrocode}
1056 % \end{macro}
1057 %
1058 % \begin{macro}{\caption@makesubcaption}
1059 % This will typeset the subcaption.
1060 % We just set all our \cs{caption}\textit{xxx} values to
1061 % the values of \cs{subcap}\textit{xxx} and typeset the
1062 % caption like \textsf{subfigure} within a \cs{hbox},
1063 % but with the help of \cs{usecaptionstyle}.
1064 %
1065 % But this is not as easy as it seems. We typeset the caption like this:
1066 % \begin{quote}
1067 % |\captionfont|\\
1068 % | {\capionlabelfont\captionlabel\captionlabeldelim}%|\\
1069 % |\captionlabelsep\captiontext|
1070 % \end{quote}
1071 % Within \textsf{subfigure} 2.0 the caption will be set quite similar to:
1072 % \begin{quote}
1073 % |\subcapsize|\\
1074 % | {\subcaplabelfont\captionlabel}%|\\
1075 % |\space\captiontext|
1076 % \end{quote}
1077 % But within \textsf{subfigure} 2.1 this has changed to:
1078 % \begin{quote}
1079 % |\subcapsize|\\
1080 % | {\subcaplabelfont\captionlabel}%|\\
1081 % |\hskip\subfiglabelskip|\\
1082 % | {\subcapfont\captiontext}}|
1083 % \end{quote}
1084 % So we have to be tricky here: We set \cs{captionlabelfont} to \cs{normalfont} plus
1085 % \cs{subcapsize} \& \cs{subcaplabelfont}, so the font setting in \cs{captionfont}
1086 % will not affect the caption label in subfigure captions.
1087 %
1088 % Note that \cs{hfil} has changed to \cs{hss} from subfigure 2.0 to 2.1,
1089 % so we use \cs{caption@subfig@hss} instead. (We will define this later on.)
1090 % \begin{macrocode}
1091 \newcommand\caption@makesubcaption[2]{%
1092 \renewcommand*\captionfont{\subcapsize\subcapfont}%
1093 \renewcommand*\captionlabelfont{\normalfont\subcapsize\subcaplabelfont}%
1094 \let\captionlabeldelim\subcaplabeldelim
1095 \let\captionlabelsep\subcaplabelsep
1096 \ifsubfigcapwidth\captionwidthtrue\else\captionwidthfalse\fi
1097 \setlength\captionmargin\subfigcapmargin
1098 \setlength\captionwidth\subfigcapwidth
1099 \captionindent\subcapindent
1100 \ifsubcapnooneline\onelinecaptionsfalse\else\onelinecaptionstrue\fi
1101 \hbox to\@tempdima{%
1102 \caption@subfig@hss\parbox[t]\@tempdima{%
1103 \captionlinewidth\@tempdima
1104 \realcaptionwidth\@tempdima
1105 \captionlabeltrue
1106 \def\captionlabel{#1}%
1107 \def\captiontext{\ignorespaces #2}%
1108 \usecaptionstyle\caption@substyle}%
1109 \caption@subfig@hss}}
1110 % \end{macrocode}
1111 % \end{macro}
1112 %
1113 % If the subfigure support is not needed, we throw
1114 % the helper macros in the garbage can.
1115 %
1116 % \begin{macrocode}
1117 \caption@package{subfigure}{@makesubfigurecaption}{%
1118 \let\setsubcapstyle\undefined
1119 \let\caption@makesubcaption\undefined}{%
1120 \ifx\@makesubfigurecaption\relax
1121 \PackageWarning{caption2}{%
1122 Option `subfigure' was set but there is no subfigure package loaded}
1123 \let\setsubcapstyle\undefined
1124 \let\caption@makesubcaption\undefined
1125 \else
1126 % \end{macrocode}
1127 %
1128 % Some stuff has changed from version 2.0 to 2.1 of the
1129 % \textsf{subfigure} package, so we make a branch here.
1130 % If \cs{subcapfont} is undefined we assume v2.0,
1131 % otherwise we assume v2.1 or newer.
1132 %
1133 % \begin{macrocode}
1134 \ifx\subcapfont\undefined
1135 \PackageInfo{caption2}{subfigure package v2.0 detected}
1136 % \end{macrocode}
1137 %
1138 % \begin{macro}{\subcapfont}
1139 % We define \cs{subcapfont} here so we can use it later
1140 % in common code for \textsf{subfigure} v2.0 and v2.1 (or newer).
1141 % \begin{macrocode}
1142 \let\subcapfont\@empty
1143 % \end{macrocode}
1144 % \end{macro}
1145 %
1146 % \begin{macro}{\subfigcapwidth}
1147 % \begin{macro}{\setsubcapmargin}
1148 % \begin{macro}{\setsubcapwidth}
1149 % Analogous to \cs{captionwidth}, \cs{setcaptionmargin}, and
1150 % \cs{setcaptionwidth} we define \cs{subfigcapwidth},
1151 % \cs{setsubcapmargin}, and \cs{setsubcapwidth}.
1152 %
1153 % Note: \cs{subfigcapmargin} is a command in v2.0 of \textsf{subfigure}.
1154 % So we make \cs{subfigcapwidth} a command, too.
1155 % \begin{macrocode}
1156 \newcommand*\subfigcapwidth{\z@}
1157 \newcommand*\setsubcapmargin{%
1158 \subfigcapwidthfalse
1159 \renewcommand*\subfigcapmargin}
1160 \newcommand*\setsubcapwidth{%
1161 \subfigcapwidthtrue
1162 \renewcommand*\subfigcapwidth}
1163 % \end{macrocode}
1164 % \end{macro}
1165 % \end{macro}
1166 % \end{macro}
1167 %
1168 % \begin{macro}{\subcaplabelsep}
1169 % Analogous to \cs{captionlabelsep} we define \cs{subcaplabelsep}.
1170 % \begin{macrocode}
1171 \newcommand*\subcaplabelsep{\space}
1172 % \end{macrocode}
1173 % \end{macro}
1174 %
1175 % \begin{macro}{\caption@subfig@hss}
1176 % This will be uses within the caption code itself.
1177 % \begin{macrocode}
1178 \let\caption@subfig@hss\hfil
1179 % \end{macrocode}
1180 % \end{macro}
1181 %
1182 % \begin{macrocode}
1183 \else
1184 \PackageInfo{caption2}{subfigure package v2.1 (or newer) detected}
1185 % \end{macrocode}
1186 %
1187 % \begin{macro}{\subfigcapwidth}
1188 % \begin{macro}{\setsubcapmargin}
1189 % \begin{macro}{\setsubcapwidth}
1190 % Analogous to \cs{captionwidth}, \cs{setcaptionmargin}, and
1191 % \cs{setcaptionwidth} we define \cs{subfigcapwidth},
1192 % \cs{setsubcapmargin}, and \cs{setsubcapwidth}.
1193 %
1194 % Note: \cs{subfigcapmargin} is a length in v2.1 of \textsf{subfigure}.
1195 % So we make \cs{subfigcapwidth} a length, too.
1196 % \begin{macrocode}
1197 \newdimen\subfigcapwidth
1198 \newcommand*\setsubcapmargin{%
1199 \subfigcapwidthfalse
1200 \setlength\subfigcapmargin}
1201 \newcommand*\setsubcapwidth{%
1202 \subfigcapwidthtrue
1203 \setlength\subfigcapwidth}
1204 % \end{macrocode}
1205 % \end{macro}
1206 % \end{macro}
1207 % \end{macro}
1208 %
1209 % \begin{macro}{\subcaplabelsep}
1210 % Analogous to \cs{captionlabelsep} we define \cs{subcaplabelsep}.
1211 % \begin{macrocode}
1212 \newcommand*\subcaplabelsep{\hskip\subfiglabelskip}
1213 % \end{macrocode}
1214 % \end{macro}
1215 %
1216 % \begin{macro}{\caption@subfig@hss}
1217 % This will be uses within the caption code itself.
1218 % \begin{macrocode}
1219 \let\caption@subfig@hss\hss
1220 % \end{macrocode}
1221 %
1222 % \end{macro}
1223 % \begin{macrocode}
1224 \fi
1225 % \end{macrocode}
1226 %
1227 % Here starts the common code for \textsf{subfigure} v2.0 and v2.1.
1228 %
1229 % \begin{macro}{\ifsubfigcapwidth}
1230 % \begin{macro}{\subcapindent}
1231 % \begin{macro}{\subcaplabeldelim}
1232 % Analogous to \cs{ifcaptionwidth}, \cs{captionindent} \& \cs{captionlabeldelim}
1233 % we define \cs{ifsubfigcapwidth}, \cs{subcapindent} \& \cs{subcaplabeldelim}
1234 % \begin{macrocode}
1235 \newif\ifsubfigcapwidth
1236 \newdimen\subcapindent
1237 \newcommand*\subcaplabeldelim{}
1238 % \end{macrocode}
1239 % \end{macro}
1240 % \end{macro}
1241 % \end{macro}
1242 %
1243 % \begin{macro}{\subcapstyle}
1244 % Analogous to \cs{captionstyle} we define \cs{subcapstyle}
1245 % and set it (via \cs{setsubcapstyle}) to a appropriate value.
1246 % \begin{macrocode}
1247 \newcommand*\subcapstyle[1]{%
1248 \expandafter\ifx\csname caption@@#1\endcsname\relax
1249 \PackageError{caption2}{Undefined caption style `#1'}{\caption@eh}%
1250 \else
1251 \def\caption@substyle{#1}%
1252 \fi}
1253 \setsubcapstyle
1254 % \end{macrocode}
1255 % \end{macro}
1256 %
1257 % \begin{macro}{\@thesubfigure}
1258 % \begin{macro}{\@thesubtable}
1259 % The \textsf{subfigure} package makes use of \cs{subcaplabelfont} and
1260 % \cs{subfiglabelskip} within its \cs{@thesub}\textit{xxx} macros.
1261 % This is totally in contrast to the way the \textsf{caption2} package
1262 % handle these settings. So we redefine the \cs{@thesub}\textit{xxx}
1263 % to be just the plain label and nothing else.
1264 %
1265 % \begin{macrocode}
1266 \renewcommand*\@thesubfigure{\thesubfigure}
1267 \renewcommand*\@thesubtable{\thesubtable}
1268 % \end{macrocode}
1269 % \end{macro}
1270 % \end{macro}
1271 %
1272 % \begin{macro}{\@makesubfigurecaption}
1273 % \begin{macro}{\@makesubtablecaption}
1274 % Now we are ready to redefine \cs{@makesubfigurecaption}.
1275 % \begin{macrocode}
1276 \let\@makesubfigurecaption\caption@makesubcaption
1277 \let\@makesubtablecaption\caption@makesubcaption
1278 % \end{macrocode}
1279 % \end{macro}
1280 % \end{macro}
1281 %
1282 % \begin{macrocode}
1283 \fi}
1284 % \end{macrocode}
1285 %
1286 % That's all folks!
1287 %
1288 % \begin{macrocode}
1289 \let\caption@package\undefined
1290 % \end{macrocode}
1291 %
1292 % \iffalse
1293 %</package>
1294 % \fi
1295 %
1296 % \begin{thebibliography}{9}
1297 % \bibitem{float}
1298 % Anselm Lingnau:
1299 % \textsl{An Improved Environment for Floats},
1300 % 2001/11/08
1301 % \bibitem{longtable}
1302 % David Carlisle:
1303 % \textsl{The longtable package},
1304 % 2000/10/22
1305 % \bibitem{rotating}
1306 % Sebastian Rahtz and Leonor Barroca:
1307 % \textsl{A style option for rotated objects in \LaTeX},
1308 % 1997/09/26
1309 % \bibitem{subfigure}
1310 % Steven Douglas Cochran:
1311 % \textsl{The subfigure package},
1312 % 2002/02/14
1313 % \bibitem{A-W:GMS94}
1314 % Michel Goossens, Frank Mittelbach and Alexander Samarin:
1315 % \newblock \textsl{The {\LaTeX} Companion},
1316 % \newblock Addison-Wesley, Reading, Massachusetts, 1994.
1317 % \bibitem{Anne}
1318 % Anne Br\"uggemann-Klein:
1319 % \textsl{Einf\"uhrung in die Dokumentverarbeitung},
1320 % B.G. Teubner, Stuttgart, 1989
1321 % \bibitem{Kopka-E}
1322 % Helmut Kopka:
1323 % \textsl{\LaTeX -- Erweiterungsm\"oglichkeiten},
1324 % 3. \"uberarbeitete Auf\/lage, Addison-Wesley, Bonn, 1991
1325 % \end{thebibliography}
1326 %
1327 % \Finale
1328 %
1329 \endinput