% threeparttable.sty   (or 3parttable) (or 3parttab on DOS)
% by Donald Arseneau   Updated on May 13, 1999.
% This file may be distributed, modified, and used in other works with just
% one restriction: modified versions must clearly indicate the modification
% (preferably by a name change).
% 
% This package facilitates tables with titles (captions) and notes. The
% title and notes are given a width equal to the body of the table (a
% tabular environment).  By itself, a threeparttable does not float, but
% you can put it in a {table} or a {table*} or some other environment.
% (This causes extra typing, but gives more flexibility.)
%
% Inside a threeparttable there should be a caption, followed by a tabular
% environment, possibly followed by a series of itemized "tablenotes".  At
% present, there is nothing automatic about the notes; you must specify the
% identifier in the body of the table ("\tnote{a}") and in the notes below
% ("\item[a]...").  I chose this method because automatic numbering with
% \footnote would be very hard to use, particularly because many tables
% make repeated reference to a single note.  If someone has a suggestion
% for a convenient, elegant, automatic system, I'll listen!  \tnote
% commands can be given in the caption too, and they will *NOT* appear in
% the list of tables. 
% 
% \begin{table}
%  \begin{threeparttable}
%   \caption{...}
%   \begin{tabular}...% or {tabular*}
%    ...\tnote{1}&....
%    ...
%   \end{tabular}
%   \begin{tablenotes}
%    \item [1] the first note
%    ...
%   \end{tablenotes}
%  \end{threeparttable}
% \end{table}

\edef\endtablenotes % make a scratch macro for restoring catcodes
  {\catcode\string `\string @=\the\catcode\string`\@
   \catcode\string `\string *=\the\catcode\string`\*}
\catcode`\@=11
\catcode`\*=11

\@ifundefined{@tempboxb}{\@nameuse{newbox}\@tempboxb}{}

\newenvironment{threeparttable}{% 3 parts: title, tabular environment, notes
\relax \ifx\\\@centercr \leavevmode \fi
\vbox\bgroup\sloppy
\@ifundefined{@captype}{\def\@captype{table}}{}%
\topsep\z@
\@enumdepth\z@
\global\let\TPT@hsize\@empty
\let\TPT@LA@caption\@caption \let\@caption\TPT@caption
\TPT@hookin\tabular\TPT@LA@tabular \TPT@hookin\tabular*\TPT@LA@tabular*
\let\TPTrlap\relax}%
{\egroup}

\def\TPT@endtab{\everyhbox{}%
\setbox\@tempboxb\lastbox   % grab tabular environment and measure it
\xdef\TPT@hsize{\hsize\the\wd\@tempboxb \parindent 1em
  \noexpand\@parboxrestore}\TPT@hsize\aftergroup\TPT@hsize
\ifx\TPT@docapt\@undefined\else
  \TPT@docapt \vskip.2\baselineskip
\fi \par \box\@tempboxb \prevdepth\z@ }

\def\TPT@hookin#1#2{\let#2#1\def#1{\edef\TPT@evh{{\the\everyhbox}}\everyhbox
  {\let\tabular\TPT@LA@tabular \let\tabular*\TPT@LA@tabular*
  \aftergroup\TPT@endtab \let\TPTrlap\rlap \everyhbox\TPT@evh}#2}}%

\gdef\TPT@hsize{}

\def\TPT@caption#1[#2]#3{\gdef\TPT@docapt
 {\par\global\let\TPT@docapt\@undefined \TPT@LA@caption{#1}[#2]{#3}}%
 \ifx\TPT@hsize\@empty\else \TPT@docapt \fi \ignorespaces}

\def\tablenotes{\TPT@hsize \list{}{\topsep\z@skip \partopsep\z@skip
\itemsep\z@ \parsep\z@ \itemindent\z@ \leftmargin1.5em
%  for superscript enumeration, use:
\def\makelabel##1{\tnote{##1}\hfil}\labelwidth .5em\labelsep .3em%
%  for on-the-line enumeration use:
% \labelwidth 1em\labelsep .5em%
\relax}}

\def\tnote#1{\protect\TPTrlap{$^{\fam\z@ #1}$}}% 
\def\TPTrlap#1{} % notes in caption will disappear in list of tables!


\endtablenotes % restore catcode of @ and * to starting value

\let\endtablenotes\endlist % and assign proper meaning for \endtablenotes!

\endinput

Example:

Here is some paragraph before the table.  Note that this table does not
float because it is not in a {table} or {table*} environment.

\begin{center}
\begin{threeparttable}
\caption{The Skewing Angles ($\beta$) for $\fam0 Mu(H)+X_2$ and
   $\fam0 Mu(H)+HX$~\tnote{a}}
\begin{tabular}{rlcc}
\hline
&   & $\fam0 H(Mu)+F_2$ & $\fam0 H(Mu)+Cl_2$ \\
\hline
&$\beta$(H)  & $80.9^\circ\tnote{b}$ & $83.2^\circ$ \\
&$\beta$(Mu) & $86.7^\circ$ & $87.7^\circ$ \\
\hline
\end{tabular}
\begin{tablenotes}
\item[a] for the abstraction reaction, $\fam0 Mu+HX \rightarrow MuH+X$.
\item[b] 1 degree${} = \pi/180$ radians.
\end{tablenotes}
\end{threeparttable}

\end{center}
