%%
%% This file is put in the Public Domain by Vincent Goulet.
%%
%% Original author of the code (and comments past this header) is
%% unknown.
%%
%% This package defines a single command \actuarialangle to typeset
%% nice looking "angles" in present value of an annuity symbols common
%% in actuarial and financial notation.
%%
%% USAGE
%%
%% In math mode
%%
%%   \actuarialangle{n}  
%%
%% to typeset "angle n". For a complete present value symbol,
%% something like
%%
%%   a_{\actuarialangle{n}}
%%
%% SHORTCUTS
%%
%% You will most likely want to use the following shortcuts:
%%
%% \angl  for \actuarialangle
%% \angln for \angl{n}
%% \anglr for \angl{r}
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{actuarialangle}

\catcode`\@=11 
\def\actuarialangle{\mathpalette\act@angle}
%
% The operation of \mathpalette causes \actuarialangle{30} to expand
% to a mathchoice. This ensures that proper sizing will be done if
% \angle is ever used outside of a first-level subscript:
%
% \mathchoice{%
% {\act@angle\displaystyle{30}}%
% {\act@angle\textstyle{30}}%
% {\act@angle\scriptstyle{30}}%
% {\act@angle\scriptscriptstyle{30}}%
% }
%
\def\act@angle#1#2{%
\mathord{%
\mkern1mu % Add a bit of preceding space
\vbox{\hrule \hbox{\vbox{%
% This amount of vertical space is the normal space for \overline in a
% subscript:
\kern3\fontdimen8\scriptfont\thr@@
\hbox{$#1#2\m@th$}}%
% Make the right-hand rule extend down to the depth of a parenthesis
% even if the symbol under the angle does not have a descender:
\setbox\z@\hbox{$#1()$}\vrule depth\dp\z@}}%
\mkern1mu}% Add a bit of following space 
}% end \act@angle
%
% \topprecedence puts a precedence number above an item, smashed so
% that the apparent height of the item is its normal height.
%
\def\topprecedence#1#2{\mathpalette{\preced@ t{}{#1}}{#2}}
%
% Put a multiplier in the empty set of braces to increase
% the spacing between the precedence number and the
% symbol to which it applies, e.g.
%
% \def\topprecedence#1#2{\mathpalette{\preced@ t{2.5}{#1}}{#2}}
%
% This also applies for \botprecedence and \vartopprecedence.
% If it is desired that all precedence numbers fall at the
% same height, regardless of whether there is an hrule between
% them and the symbol to which they apply, then make
% \topprecedence the same as \vartopprecedence.
%
\def\botprecedence#1#2{\mathpalette{\preced@ b{}{#1}}{#2}}
%
% \vartopprecedence provides extra space below the top
% symbol, to accommodate an intervening hrule.
%
\def\vartopprecedence#1#2{\mathpalette{\preced@ t3{#1}}{#2}}
%
% In \preced@, #1 is `t' for top or `b' for bottom, #2 is a
% multiplier for the space between the top and bottom symbols (may
% be empty), #3 is the first argument from the user, #4 is
% \displaystyle or \textstyle or \scriptstyle or
% \scriptscriptstyle, from \mathpalette, and #5 is the second
% argument given by the user. This peculiar ordering of the
% arguments is done to work around the restriction of \mathpalette
% that it only reads 2 arguments.
%
\def\preced@#1#2#3#4#5{%
% Measure the arguments:
\setbox\tw@\hbox{$\m@th#4#3$}%
\setbox\z@\hbox{$\m@th#4#5$}\dimen@\wd\z@
\vbox{% to\ht\z@{%
\baselineskip\z@skip
% \lineskip is set using AMSTeX's \ex@, if available, for a slight
% refinement in the spacing if this macro is used in eightpoint
% text. If \ex@ is not available, \p@ is used.
\lineskip#2\ifx\UNDEFINED\ex@\p@\else\ex@\fi\relax
\lineskiplimit\lineskip 
\if b#1\relax\box\z@\else\vss\fi
\hbox to\dimen@{\hss\unhbox\tw@\hss}%
\if t#1\relax\box\z@\else\vss\fi
}% end \vbox
}% end \preced@
% Restore the category code of the @ character:
\catcode`\@=11
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%To get a little more space after stuff under the angle, define \angl 
% in the following way:
%
\def\angl#1{{\actuarialangle{{#1}\mkern2mu}}}
%
%
\def\angln{{\angl n}}
%
\def\anglr{{\angl r}}
%
\def\lift#1#2{{\topprecedence{#1}{#2}}}
%%
%% End of file `actuarialangle.sty'.
