% @(#)acronym.sty       1.2 9/11/90 Copyright 1989 ICL
% 
% Author: John Kewley
%
% This style file contains macros for acronyms.
%
% Two styles are supported - footnote and parenthesised.
% This can be switched using \foottrue for footnotes or
% \footfalse (default) for parenthesised.
%
% Parenthesised acronyms are used as follows:
% 	Declare acronym using:
%		\newacronym{latex name}{expanded name}[printed name]
%		(The printed name defaults to latex name).
%		e.g. \acronym{GNU}{GNU Not Unix}[\sc{gnu}]
%	When acronym is first used (\GNU), the following is printed:
%		expanded name (printed name)
%		GNU Not Unix (GNU)
%	Subsequent use yields only the printed name.
%
% Footnote acronyms work in the same way except when they are first used:
%	printed name\footnote{expanded name}
%
% Acronyms can be followed by an optional argument:
%		\newacronym{PE}{Processing Element}
%		\PE['s] gives
%		Processing Element's (PE's)
%
% They can also be followed by s to signify the plural:
%		\newacronym{PE}{Processing Element}
%		\PEs gives
%		Processing Elements (PEs)
%
% If they are to be referred to before they are first used, in a title say
% When full expansion might not look good, or in a section heading where
% the definition would not be wanted in the contents list, short and long forms
% of the acronym are defined.
%
% e.g. \section{\GNUshort\ Comings}
%
% The long version can be used where a repetition of the full name is required.
%
% Quite often acronyms are defined in a Glossary, Terminology or
% Table of Acronyms. The item command is provided for this:
%
%		\GNUitem gives
%		\item[GNU] GNU Not Unix
%
% Whenever an acronym is defined using \newacronym, all the above forms are
% available.
%
% John Kewley ICL
%
% jk@r6.cs.man.ac.uk or
% jk@nw.stl.stc.co.uk
 
% Auxiliary definitions:
 
%	\ifnextchar
%\def\ifnextchar#1#2#3{\@ifnextchar#1{#2}{#3}}
 
\def\namegdef#1{\expandafter\gdef\csname #1\endcsname}
\def\namedef#1{\expandafter\def\csname #1\endcsname}
\def\nameuse#1{\csname #1\endcsname}
 
\newif\iffoot \footfalse
 
\def\acitemx#1#2[#3]{\item [#1#3] #2#3}
\def\acitem#1#2{\@ifnextchar [{\acitemx{#1}{#2}}{\acitemx{#1}{#2}[]}}
\def\acfootx#1#2[#3]{#1#3\footnote{#2#3}}
\def\acfoot#1#2{\@ifnextchar [{\acfootx{#1}{#2}}{\acfootx{#1}{#2}[]}}
\def\aclongx#1#2[#3]{#1#3 (#2#3)}
\def\aclong#1#2{\@ifnextchar [{\aclongx{#1}{#2}}{\aclongx{#1}{#2}[]}}
\def\acshortx#1[#2]{#1#2}
\def\acshort#1{\@ifnextchar [{\acshortx{#1}}{\acshortx{#1}[]}}
\def\acronx#1#2[#3]{\iffoot\acfoot{#1}{#2}[#3]\else\aclong{#1}{#2}[#3]\fi}
\def\acron#1#2{\@ifnextchar [{\acronx{#1}{#2}}{\acronx{#1}{#2}[]}}
 
\def\newacaux#1#2{\namegdef{#1x}[##1]{#2##1}%
	\namegdef{#1}{\protect\@ifnextchar [{\protect\nameuse{#1x}}{#2}}}
\def\newac#1#2[#3]{%
	\namegdef{#1item}{\acitem{#3}{#2}}
	\namegdef{#1items}{\acitem{#3s}{#2s}}
	\namegdef{#1long}{\protect\aclong{#2}{#3}}
	\namegdef{#1longs}{\protect\aclong{#2s}{#3s}}
	\namegdef{#1short}{\protect\acshort{#3}}
	\namegdef{#1shorts}{\protect\acshort{#3s}}
	\namegdef{#1foot}{\protect\acfoot{#3}{#2}}
	\namegdef{#1foots}{\protect\acfoot{#3s}{#2s}}
	\namegdef{#1x}[##1]{\acron{#2##1}{#3##1}\newacaux{#1}{#3}}
	\namegdef{#1s}{\protect\nameuse{#1x}[s]}
	\namegdef{#1}{\protect\@ifnextchar [{\protect\nameuse{#1x}}%
		{\protect\acronx{#2}{#3}[]\protect\newacaux{#1}{#3}}}}
 
\def\termit#1#2[#3]{\newac{#1}{#2}[#3]\acitem{#3}{#2}}
\def\termitem#1#2{\@ifnextchar [{\termit{#1}{#2}}{\termit{#1}{#2}[#1]}}
 
\def\newte#1#2[#3]{\namegdef{#1item}{\acitem{#3}{#2}}}
\def\newterm#1#2{\protect\@ifnextchar [{\newte{#1}{#2}}{\newte{#1}{#2}[#1]}}
 
% \newacronym
%     #1 : short name
%     #2 : long name
%   [#3] : optional printed name
\def\newacronym#1#2{\@ifnextchar [{\newac{#1}{#2}}{\newac{#1}{#2}[#1]}}
