research/papers/pricing/subfigure.sty

447 lines
18 KiB
TeX

%$% 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}[2005/03/06 v2.0 subfigure package]
\typeout{Package: subfigure 2005/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'.