summaryrefslogtreecommitdiff
path: root/obsolete/macros/latex209/contrib/misc/subfigure.sty
blob: b8a448e7f96e14f7d0a2b321121a9303f5b6b408 (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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
%$% subfigure.sty
%$% Subfigure/table command for use with the LaTeX figure environment.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Copyright (C) 1988-1995 Steven Douglas Cochran.
%%%
%%% The subfigure style is made available for academic and research
%%% purposes only.  No commercial license is hereby granted.  Copying
%%% and other reproduction is authorized only for research, education,
%%% and other non-commercial purposes.  No warranties, either
%%% expressed or impiled, are made regarding the operation, use, or
%%% results of the subfigure style.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% @LaTeX-style-file{
%%%    Author              = "Steven Douglas Cochran",
%%%    Version             = "2.0 (LaTeX209 version)",
%%%    Date                = "1995 Mar 06",
%%%    Time                = "12:43:14 EDT",
%%%    Filename            = "subfigure.sty",
%%%    Address             = "Digital Mapping Laboratory
%%%                           School of Computer Science
%%%                           Carnegie-Mellon University
%%%                           5000 Forbes Avenue
%%%                           Pittsburgh, PA 15213-3891
%%%                           USA",
%%%    Telephone           = "(412) 268-5654",
%%%    FAX                 = "(412) 268-5576",
%%%    checksum            = "23098 438 1899 18286",
%%%    Email               = "sdc+@CS.CMU.EDU (Internet)",
%%%    CodeTable           = "ISO/ASCII",
%%%    Keywords            = "LaTeX, float, figure, table",
%%%    Supported           = "yes",
%%%    Abstract            = "LaTeX document-style option for
%%%                           providing support for the inclusion of
%%%                           small `sub' figures and tables.  It
%%%                           simplifies the positioning, captioning
%%%                           and labeling of them within a single
%%%                           figure or table environment.",
%%%    DocString           = "The checksum field above contains a CRC-16
%%%                           checksum as the first value, followed by
%%%                           the equivalent of the standard UNIX wc
%%%                           (word count) utility output of lines,
%%%                           words, and characters.  This is produced
%%%                           by Robert Solovay's checksum utility."
%%% }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% $Log:       subfigure.sty,v $
%$%  Revision 2.0  95/03/06  12:43:14  sdc
%$%  This version of `subfigure' is the first to be ported to LaTeX2e
%$%  (with backward compatibility to LaTeX 2.09).  "\subfigure" and
%$%  "\subtable" are now identical and the environment controls
%$%  internal differences between them.  Now, the caption setting
%$%  portion of "\@subfloat" is broken into the separate macros
%$%  "\@makesubfigurecaption" and "\@makesubtablecaption" to allow a
%$%  separate hook for the modification of how the caption is
%$%  constructed and to allow the table and figure captions to be
%$%  different.  In addition, support of the `normal', `hang',
%$%  `center', `centerlast', 'nooneline'; `scriptsize', \ldots,
%$%  `Large'; `up', `it', `sl', `sc', `md', `bf', `rm', `sf', and `tt'
%$%  package options were added for compatibility with the caption.sty
%$%  by H.A. Sommerfeldt.}  
%$%  
%$%  Revision 1.6  93/05/13  12:58:34  sdc
%$%  Changed to use the \thefigure macro in building the referenced
%$%  label.  The old form caused a problem when used with the
%$%  report.sty as pointed out by Andrew Anselmo
%$%  (anselmo@cumesb.mech.columbia.edu).  Also modified to restrict
%$%  the scope of the subfigure \label to the body of the subfigure.
%$%  Added \@thesubfigure to allow a separate labeling of the
%$%  subfigure in the figure and in the text.  By default it is the
%$%  same as \thesubfigure with space appended.  Added some hooks to
%$%  print the subfigure captions to the list-of-figures file if
%$%  desired.  Finally, added the corresponding support for sub-tables
%$%  as well as sub-figures.  NOTE: the optional caption is now a
%$%  moving argument and any fragile commands that appear in the
%$%  caption must be preceded by a \protect (just like that of the
%$%  \caption command).
%$%   
%$%  Revision 1.5  92/08/11  23:13:12  sdc
%$%  Fixed a bug which caused an problem with captions that contained  
%$%  expressions like \sqrt;  This was pointed out by Tom Scavo
%$%  (scavo@cie.uoregon.edu).  A separate bug was fixed which caused
%$%  different sized captions to be misaligned;  This problem was
%$%  pointed out by Simon Marshall (S.Marshal@Hull.ac.uk).  Also
%$%  cleaned up the code a mite and *changed* the figure spacing so that
%$%  if no optional section is given, then the figure is only followed
%$%  by \subfigbottomskip and not that plus (\subfigcapskip + \strut
%$%  height).  This should make it easier to adjust spacing as desired.
%$%   
%$%  Revision 1.4  92/06/27  10:40:34  sdc
%$%  Added a hack to allow the \label command to be used within the
%$%  body of the subfigure giving a reference label in the form
%$%  \arabic{thefigure}\thesubfigure.  Added standard file header for
%$%  style.  
%$%   
%$%  Revision 1.3  90/10/22  17:04:28  cochran
%$%  Changed test for empty caption inside of \@subfigure to compare
%$%  tokens and not the caption vs. \@empty.  The former (incorrect)
%$%  test caused an error when the first two letters of the caption
%$%  were the same.
%$%
%$%  Revision 1.2  89/08/30  07:18:29  cochran
%$%  Added a separate bottom margin and expanded the comments.
%$%
%$%  Revision 1.1  88/11/02  11:03:46  cochran
%$%  Initial revision.
%$%
%$%  05 Mar 86  cochran@dworkin.usc.edu (USC-IRIS)
%$%  Created.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%$% Usage:  \documentstyle[...,subfigure,...]{...}
%$%
%$%             \subfigure[CAPTIONtext]{FIGUREbox}
%%%
%%% Creates a subfigure box with an optional CAPTION under a FIGURE.
%%% The FIGURE is centered with \subfigtopskip of vertical space added
%%% above.  If there is a CAPTION, then \subfigcapskip vertical space
%%% is added below the FIGURE followed by the CAPTION.  Finally,
%%% \subfigbottomskip of vertical space added at the bottom.  
%%%
%%% If a CAPTION is given (including a null CAPTION `[]') then the
%%% subfigure is labeled with a counter formatted by the macro
%%% `\thesubfigure' which returns `(a)', `(b)', etc.  If desired,
%%% this macro may be redefined.  The counter used for labeling the
%%% subfigures is `subfigure' and is incremented for each subfigure
%%% regardless of whether a CAPTION was printed.
%%%
%$%             \subfigure[CAPTIONtext]{FIGUREbox}
%%%
%%% The subtable command is symmetric to the subfigure command defined
%%% above.   
%%%
%%% One example of use is to surround the figure in a center
%%% environment or to specifying \centering:
%%%
%%%                                          *---------*   
%%%   \newcommand{\goodgap}{%                |  ..   . |   *---------*  
%%%     \hspace{\subfigtopskip}%             |  .   .  |   | . .  .  |  
%%%     \hspace{\subfigbottomskip}}          | .. . .  |   | .  . .. |  
%%%   ...                                    *---------*   *---------*    
%%%   \begin{figure}%                         (a) First     (b) Second   
%%%     \centering                                          Figure 
%%%     \subfigure[First]{...}\goodgap      
%%%     \subfigure[Second Figure]{...}\\           *---------*
%%%     \subfigure[Third]{\label{3figs-c}...}%     | . .. .  |
%%%     \caption{Three Subfigures.}                | . .. .  |
%%%     \label{3figs}                              *---------*
%%%   \end{figure}                                  (c) Third
%%%   ...                                   Figure 1. Three Subfigures.    
%%%   Figure~\ref{3figs} contains        
%%%   two top `subfigures' and           Figure 1 contains two top `sub-
%%%   Figure~\ref{3figs-c}.              figures' and Figure 1(c).
%%%
%%% A second example is to change the way that the subfigures are labeled
%%% and to have the subfigure captions printed in the list-of-figures.
%%%
%%%   \renewcommand{\thesubfigure}{\thefigure.\arabic{subfigure}}
%%%   \makeatletter
%%%     \renewcommand{\@thesubfigure}{\thesubfigure:\space}
%%%     \renewcommand{p@subfigure}{}
%%%   \makeatother
%%%   ...
%%%   \setcounter{lofdepth}{2}
%%%   \listoffigures
%%%   ...
%%%   \begin{figure}%
%%%     \begin{center}%
%%%       \subfigure[First]{%         *--------------*  *--------------*   
%%%         \label{fig:first}%        |  ..   .  .   |  | . ... .. . . |  
%%%         ...}%                     |  .  .   .  . |  | .  .  . . .. |  
%%%       \goodgap                    | .. . .  . .  |  | . . . .. ..  |
%%%      \subfigure[Second]{%         *--------------*  *--------------*   
%%%         \label{fig:second}%  
%%%         ...}%                        1.1: First        1.2: Second
%%%     \end{center}%
%%%     \caption{Two Subfigures.}          Figure 1. Two Subfigures.
%%%   \end{figure}                   
%%%   ...                             See subfigures 1.1 and 1.2.  
%%%   See subfigures \ref{fig:first}  
%%%   and \ref{fig:second}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Options:
%%%
%%%  I. Subfloat caption shape.
%%%     By default the caption paragraphs are centered under the
%%%     subfigure or table with a little indentation at each side.
%%%     There are three options that may be used to change the shape
%%%     of the centered paragraph -- they only have an effect when the
%%%     caption is more than one line long.  These should be set in
%%%     the preamble of your LaTeX file:
%%%     
%%%          \subcaphangtrue        Causes the label to be a hanging
%%%                                 indentation to the caption paragraph.
%%%          \subcapcentertrue      Causes each line of the paragraph
%%%                                 to be separately centered.
%%%          \subcapcenterlasttrue  Causes the last line only to be 
%%%                                 centered.
%%%          \subcapnooneline       If a caption fits on one line it
%%%                                 will, by default, be centered.
%%%                                 This option left-justifies the one
%%%                                 line caption.
%%%
%%%     The hang option may be used in addition to either center
%%%     option.  (If both center options are true it is the same as if
%%%     only the \subcapcenter was true.)
%%%     
%%%     
%%% II. Subfloat label font.
%%%     The subfloat label font may be separately set by changing the
%%%     definition of \subcaplabelfont.  For example:
%%%     
%%%          \newcommand{\subcaplabelfont}{\it}
%%%     
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%
%%%  Identification
%%%
\ifx\if@compatibility\undefined\else
  \NeedsTeXFormat{LaTeX2e}
  \ProvidesPackage{subfigure}[1995/03/06 v2.0 subfigure package]
  \typeout{Package: subfigure 1995/03/06 v2.0}
\fi

%%%
%%%  Initialization and Shared constants
%%%
\newif\ifsubcaphang
\newif\ifsubcapcenter
\newif\ifsubcapcenterlast
\newif\ifsubcapnooneline

%%
%% Common values (mention of `subfig' in names is for upward compatibility)
%%
\newcommand{\subfigtopskip}{10pt}    % Length from the top of the subfloat
                                     %   box to the begining of the FIGURE box.
\newcommand{\subfigbottomskip}{10pt} % Length from the bottom of the CAPTION
                                     %   to the bottom of the subfloat.
\newcommand{\subfigcapskip}{10pt}    % Length from the bottom of the FIGURE box
                                     %   to the begining of the CAPTION.
\newcommand{\subfigcapmargin}{10pt}  % Indentation of the caption from the
                                     %   sides of the subfloat box (This should
                                     %   always be positive).
\newcommand{\subcapsize}{}           % Size of the CAPTION font.
\newcommand{\subcaplabelfont}{}      % Font of the caption label.

%%
%% Subfigure values
%%
\newcounter{subfigure}[figure]          % Subfigure counter.
\def\thesubfigure{(\alph{subfigure})}   % Generate CAPTION label (text).
\newcommand{\@thesubfigure}{%           % Generate CAPTION label (figure).
  {\subcaplabelfont\thesubfigure}\space}
\let\p@subfigure\thefigure              % Figure number for \label.

\let\ext@subfigure\ext@figure           % Default SubFigure file extension.
\newcommand{\l@subfigure}{%             % How to print an LOF subfigure line.
  \@dottedxxxline{\ext@subfigure}{2}{3.9em}{2.3em}}
\newcounter{lofdepth}                   % LOF depth counter.
\setcounter{lofdepth}{1}                % Default is to NOT print an LOF line.

%%
%% Subtable values
%%
\newcounter{subtable}[table]            % Subtable counter.
\def\thesubtable{(\alph{subtable})}     % Generate CAPTION label (text).
\newcommand{\@thesubtable}{%            % Generate CAPTION label (figure).
  {\subcaplabelfont\thesubtable}\space}
\let\p@subtable\thetable                % Figure number for \label.

\let\ext@subtable\ext@table             % Default SubTable file extension.
\newcommand{\l@subtable}{%              % How to print an LOT subtable line.
  \@dottedxxxline{\ext@subtable}{2}{3.9em}{2.3em}}
\newcounter{lotdepth}                   % LOT depth counter.
\setcounter{lotdepth}{1}                % Default is to NOT print an LOT line.


%%
%% Declaration of options
%%
\ifx\if@compatibility\undefined
  \subcaphangfalse
  \subcapcenterfalse
  \subcapcenterlastfalse
  \subcapnoonelinefalse
  \def\subcapsize{\footnotesize}
\else
  \DeclareOption{normal}{%
    \subcaphangfalse
    \subcapcenterfalse
    \subcapcenterlastfalse}
  \DeclareOption{hang}{\subcaphangtrue}
  \DeclareOption{center}{\subcapcentertrue}
  \DeclareOption{centerlast}{\subcapcenterlasttrue}
  \DeclareOption{nooneline}{\subcapnoonelinetrue}
  \DeclareOption{isu}{\ExecuteOption{hang}}
  \DeclareOption{anne}{\ExecuteOption{centerlast}}

  \DeclareOption{scriptsize}{\renewcommand{\subcapsize}{\scriptsize}}
  \DeclareOption{footnotesize}{\renewcommand{\subcapsize}{\footnotesize}}
  \DeclareOption{small}{\renewcommand{\subcapsize}{\small}}
  \DeclareOption{normalsize}{\renewcommand{\subcapsize}{\normalsize}}
  \DeclareOption{large}{\renewcommand{\subcapsize}{\large}}
  \DeclareOption{Large}{\renewcommand{\subcapsize}{\Large}}
  \DeclareOption{up}{\renewcommand{\subcaplabelfont}{\upshape}}
  \DeclareOption{it}{\renewcommand{\subcaplabelfont}{\itshape}}
  \DeclareOption{sl}{\renewcommand{\subcaplabelfont}{\slshape}}
  \DeclareOption{sc}{\renewcommand{\subcaplabelfont}{\scshape}}
  \DeclareOption{md}{\renewcommand{\subcaplabelfont}{\mdseries}}
  \DeclareOption{bf}{\renewcommand{\subcaplabelfont}{\bfseries}}
  \DeclareOption{rm}{\renewcommand{\subcaplabelfont}{\rmfamily}}
  \DeclareOption{sf}{\renewcommand{\subcaplabelfont}{\sffamily}}
  \DeclareOption{tt}{\renewcommand{\subcaplabelfont}{\ttfamily}}

  \ExecuteOptions{normal,footnotesize}
  \ProcessOptions
\fi


%%%
%%% Define the subfigure and subtable commands
%%%
\newcommand{\subfigure}{%
  \bgroup
    % Since the table caption is usually generated later, we
    % must locally anticipate the future value of its counter.  
    \advance\csname c@\@captype\endcsname\@ne
    \refstepcounter{sub\@captype}%
    \leavevmode
    \@ifnextchar [%
      {\@subfloat{sub\@captype}}%
      {\@subfloat{sub\@captype}[\@empty]}}
\let\subtable\subfigure

%%%
%%% Define the common subfloat macro
%%%
\def\@subfloat#1[#2]#3{%
    \setbox\@tempboxa \hbox{#3}%
    \@tempdima=\wd\@tempboxa
    \vtop{%
      %% Put the top spacing and the figure in the top box
      \vbox{%
        \vskip\subfigtopskip
        \box\@tempboxa}%
      %% Now skip down and add the caption paragraph
      %%   (unless #2 == \@empty)
      \ifx \@empty#2\relax \else
        \vskip\subfigcapskip
        \@subcaption{#1}{#2}%
      \fi
      %% Finally add the bottom spacing.
      \vskip\subfigbottomskip}%
  \egroup}

\newcommand{\@subfigcaptionlist}{}

\newcommand{\@subcaption}[2]{%
  \begingroup
    \let\label\@gobble
    \def\protect{\string\string\string}%
    \xdef\@subfigcaptionlist{%
      \@subfigcaptionlist,%
      {\protect\numberline {\@currentlabel}%
       \noexpand{\ignorespaces #2}}}%
  \endgroup
  \@nameuse{@make#1caption}{\@nameuse{@the#1}}{#2}}

\newcommand{\@makesubfigurecaption}[2]{%
  \setbox\@tempboxa \hbox{%
    \subcapsize
    \ignorespaces #1%
    \ignorespaces #2}%
  \@tempdimb=-\subfigcapmargin
  \multiply\@tempdimb\tw@
  \advance\@tempdimb\@tempdima
    \hbox to\@tempdima{%
      \hfil
      \ifdim \wd\@tempboxa >\@tempdimb
        \subfig@caption{#1}{#2}%
      \else\ifsubcapnooneline
        \subfig@caption{#1}{#2}%
      \else 
        \box\@tempboxa
      \fi\fi
      \hfil}}

\let\@makesubtablecaption\@makesubfigurecaption

\newcommand{\subfig@caption}[2]{%
  \ifsubcaphang
    \sbox{\@tempboxa}{%
      \subcapsize
      \ignorespaces #1}%
    \addtolength{\@tempdimb}{-\wd\@tempboxa}%
    \usebox{\@tempboxa}%
    \subfig@captionpar{\@tempdimb}{#2}%
  \else
    \subfig@captionpar{\@tempdimb}{#1#2}%
  \fi}

\newcommand{\subfig@captionpar}[2]{%
  \parbox[t]{#1}{%
    \strut
    \ifsubcapcenter
      \setlength{\leftskip}{\@flushglue}%
      \setlength{\rightskip}{\@flushglue}%
      \setlength{\parfillskip}{\z@skip}%
    \else\ifsubcapcenterlast
      \addtolength{\leftskip}{0pt plus 1fil}%
      \addtolength{\rightskip}{0pt plus -1fil}%
      \setlength{\parfillskip}{0pt plus 2fil}%
    \fi\fi
    \subcapsize
    \ignorespaces #2}}

%%%
%%% Generalized wrapper for the \@dottedtocline macro.  This checks for
%%% the level based on the output file (#1) and not using only
%%% \@tocdepth.  
%%%
\newcommand{\@dottedxxxline}[6]{%
  \ifnum #2>\@nameuse{c@#1depth}\else
    \@dottedtocline{0}{#3}{#4}{#5}{#6}
  \fi}

%%%
%%% Finally, wrap the \@caption macro to dump any sub-captions saved
%%% after calling the standard \@caption.
%%%
\let\subfig@oldcaption\@caption

\long\def\@caption#1[#2]#3{%
  \subfig@oldcaption{#1}[{#2}]{#3}%
  \@for \@tempa:=\@subfigcaptionlist \do {%
    \ifx\@empty\@tempa\relax \else
      \addcontentsline
        {\@nameuse{ext@sub#1}}%
        {sub#1}%
        {\@tempa}%
    \fi}%
  \gdef\@subfigcaptionlist{}}
\endinput

%%% 
%%% End of file `subfigure.sty'.