summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/actuarialangle/actuarialangle.sty
blob: 6c79423ec53ba8d06b07a69179200a49cf5caba2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
%%
%% 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'.