% subfloat.sty:    set sub-number within one float
% Iwakuma Tetsuo (bear@hashi1.civil.tohoku.ac.jp)  8/7/1992
%                                                10/10/1992
%                   header control added       4/19-22/1993
%                   header control added           8/7/1993
\@definecounter{subfloatnumber}
\def\@T@bLe{table}
\def\subfloatcap{-\alph{subfloatnumber}} % default

\newif\if@subfloatcaptionhead \@subfloatcaptionheadtrue
\def\NoSubfloatCaptionHead{\@subfloatcaptionheadfalse}

\newif\if@subfloatwithcaptionhead
\def\subcaption{\@ifstar{%
 \@subfloatwithcaptionheadfalse\subc@ption}{%
 \@subfloatwithcaptionheadtrue\subc@ption}}

\def\subc@ption{\@addtoreset{subfloatnumber}{\@captype}%
\ifx\@captype\@T@bLe\relax\else\addtocounter{\@captype}{1}\fi%
\def\the@subfloatnumber{\csname the\@captype\endcsname\subfloatcap}%
\stepcounter{subfloatnumber}%
\edef\@currentlabel{\csname the@subfloatnumber\endcsname}%
\@dblarg{\@subcaption\@captype}}

\long\def\@subcaption#1[#2]#3{\par\addcontentsline{\csname
  ext@#1\endcsname}{#1}{\protect\numberline{\csname
  the#1\endcsname\subfloatcap}{\ignorespaces #2}}\begingroup
    \@parboxrestore
    \small
   \if@subfloatcaptionhead
    \if@subfloatwithcaptionhead
     \@makecaption{\csname fnum@#1\endcsname\subfloatcap}%
         {\ignorespaces #3}\par
    \else
     \@makecaptionWOheading{\subfloatcap}{\ignorespaces #3}
    \fi
   \else\@makecaptionWOheading{}{\ignorespaces #3}\par\fi
    \endgroup%
     \ifx\@captype\@T@bLe\relax\else\addtocounter{\@captype}{-1}\fi}

\long\def\@makecaptionWOheading#1#2{%
   \vskip 10\p@
   \setbox\@tempboxa\hbox{#1 #2}%
   \ifdim \wd\@tempboxa >\hsize
       #1 #2\par
     \else
       \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
   \fi}

\endinput
% ----- example follows ----
\documentstyle[subfloat]{article}
\title{about {\tt subfloat.sty}}
\author{the author}
\date{Aug. 7, 1993}
\unitlength=1mm
\def\subpicture#1{\begin{picture}(50,7)(0,0)
\put(0,0){\framebox(50,7){#1}}\end{picture}}
\begin{document}
\maketitle

\begin{enumerate}
\item Subcaptions are specified by \verb+\subcaption{...}+ or
 \verb+\subcaption*{...}+. While the former sets a heading
 with for example `Figure' and figure number with subnumber,
 the latter sets only the subnumber.
\item Always need to specify the main \verb+\caption{...}+.
\item Figure captions are always located BELOW the figures, while
 table captions are ABOVE the tables including the main caption.
\item Subnumber system can be set by \verb+\subfloatcap+.
 Its default is
 \begin{verbatim}
 \def\subfloatcap{-\alph{subfloatnumber}}
 \end{verbatim}
\item \verb+\NoSubfloatCaptionHead+ will remove headings
 for subcaptions such as `Figure' or `Table' plus figure numbers.
\end{enumerate}

In the case of figures, we need to set
\begin{verbatim}
\begin{figure}[h]
  ......
    \subcaption{First Figure}
     \label{fig:1}
  ......
    \subcaption{Second Figure}
     \label{fig:2}
\caption{Three Subfigures}
\label{fig:all}
\end{figure}
\end{verbatim}

Then typical outputs are shown in the {\bf Fig. \ref{fig:all}}.
\begin{figure}[t]
  \begin{center}
   \subpicture{First}
    \subcaption{First Figure}
     \label{fig:1}
  \end{center}
  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{Second}
     \subcaption{Second Figure}
      \label{fig:2}
   \end{center}
  \end{minipage}
  ~
  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{Third}
     \subcaption{Third Figure}
      \label{fig:3}
   \end{center}
  \end{minipage}
\caption{Three Subfigures}
\label{fig:all}
\end{figure}

On the other hand, {\bf Fig. \ref{fig:all2}} shows a modified
caption without figure number but with subnumber
 using \verb+\subcaption*+, where the subnumber is set to
\begin{verbatim}
 \def\subfloatcap{(\alph{subfloatnumber})}
\end{verbatim}

\begin{figure}[b]
 \def\subfloatcap{(\alph{subfloatnumber})}
  \begin{center}
   \subpicture{Fourth}
    \subcaption*{Fourth Figure}
     \label{fig:4}
  \end{center}
  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{Fifth}
     \subcaption*{Fifth Figure}
      \label{fig:5}
   \end{center}
  \end{minipage}
  ~
  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{Sixth}
     \subcaption*{Sixth Figure}
      \label{fig:6}
   \end{center}
  \end{minipage}
\caption{The Next Three Subfigures}
\label{fig:all2}
\end{figure}

Of course, you can refer to these figures individually. For example,
\begin{verbatim}
  {\bf Fig. \ref{fig:5}} shows that the results given in
  {\bf Figs. \ref{fig:1}} and {\bf \ref{fig:2}} can be $\cdots$.
\end{verbatim}
will result in \vspace{2ex}

\fbox{\begin{minipage}{.75\textwidth}
{\bf Fig. \ref{fig:5}} shows that the results given in
{\bf Figs. \ref{fig:1}} and {\bf \ref{fig:2}} can be $\cdots$.
\end{minipage}}\vspace{2ex}

The default of the numbering system is shown above, and can be
changed by redefining \verb+\subfloatcap+ also shown above.
The examples of table environment in the next page use a new
definition as
\begin{verbatim}
     \def\subfloatcap{-(\roman{subfloatnumber})}
\end{verbatim}

\def\subfloatcap{-(\roman{subfloatnumber})}
\begin{verbatim}
\begin{table}[h]
\caption{Three Subtables}
\label{tab:all}
  ......
    \subcaption{First Table}
     \label{tab:1}
  ......
    \subcaption{Second Table}
     \label{tab:2}
\end{table}
{\bf Table. \ref{tab:1}} shows that $\cdots$ because $\cdots$ as
shown in {\bf Tables \ref{tab:3}} and {\bf \ref{tab:6}}.
\end{verbatim}
\begin{table}[t]
\caption{Three Subtables}
\label{tab:all}
  \begin{center}
   \subpicture{First}
    \subcaption{First Table}
     \label{tab:1}
  \end{center}
  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{Second}
     \subcaption{Second Table}
      \label{tab:2}
   \end{center}
  \end{minipage}
  ~
  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{Third}
     \subcaption{Third Table}
      \label{tab:3}
   \end{center}
  \end{minipage}
\end{table}

\begin{table}[b]
\caption{The Next Three Subtables}
\label{tab:all2}
  \begin{center}
   \subpicture{Fourth}
    \subcaption{Fourth Table}
     \label{tab:4}
  \end{center}
  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{Fifth}
     \subcaption{Fifth Table}
      \label{tab:5}
   \end{center}
  \end{minipage}
  ~
  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{Sixth}
     \subcaption{Sixth Table}
      \label{tab:6}
   \end{center}
  \end{minipage}
\end{table}
{\bf Table. \ref{tab:1}} shows that $\cdots$ because $\cdots$ as
shown in {\bf Tables \ref{tab:3}} and {\bf \ref{tab:6}}.

If you do NOT need a header of subsections, insert a line of
\begin{verbatim}
    \NoSubfloatCaptionHead
\end{verbatim}
at an appropriate position in that specific figure environment.

\begin{figure}[t]
\NoSubfloatCaptionHead
  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{First}
     \subcaption{First Figure}
   \end{center}
  \end{minipage}
  ~
  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{Second}
     \subcaption{Second Figure}
   \end{center}
  \end{minipage}

  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{Third}
     \subcaption{Third Figure}
   \end{center}
  \end{minipage}
  ~
  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{Fourth}
     \subcaption{Fourth Figure}
   \end{center}
  \end{minipage}
\caption{Four Subfigures without headers}
\end{figure}

\begin{figure}[b]
  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{First}
     \subcaption{First Figure}
   \end{center}
  \end{minipage}
  ~
  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{Second}
     \subcaption{Second Figure}
   \end{center}
  \end{minipage}

  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{Third}
     \subcaption{Third Figure}
   \end{center}
  \end{minipage}
  ~
  \begin{minipage}[t]{.47\textwidth}
   ~
   \begin{center}
    \subpicture{Fourth}
     \subcaption{Fourth Figure}
   \end{center}
  \end{minipage}
\caption{Four Subfigures with headers}
\end{figure}

\end{document}
