350 TUGboat, Volume 38 (2017), No. 3

Typesetting actuarial symbols easily and consistently with actuarialsymbol and actuarialangle David Beauchemin and Vincent Goulet Abstract Actuarial notation is characterized by subscripts and Figure 1: “Actuariat” (French for ) written using actuarial symbols on the 1972 graduating superscripts on both sides of a principal symbol, num- class mosaic at Universit´eLaval bers positioned above or below subscripts, and some otherwise unusual symbols. The pair of packages actuarialsymbol and actuarialangle provides all sons but imported by the latter, provides the angle the facilities to compose actuarial symbols of life and overhead angle bracket symbols. contingencies and financial mathematics, easily and consistently. 2 Existing alternatives Authors often use ad hoc constructions like 1 Introduction {}_tA_x to put subscripts and superscripts in front of a sym- , the “engineers of ”, denote var- bol. This notation quickly becomes a nightmare to ious quantities of life contingencies using a whole parse mentally and the source code has little relation- array of symbols. The highly descriptive, yet com- ship to the actual significance of the symbol. That pact, notation was standardized as far back as in said, the worst practical drawback to this approach 1898 [10]. Figure 1 shows a creative use of the no- is probably that there is no way to ensure that sub- tation by the graduating class of 1972 in Actuarial scripts and superscripts on either side of the principal Science at Universit´eLaval. symbol are aligned vertically. As most readers of TUGboat are probably unfa- The package mathtools [5] provides a command miliar with actuarial notation, let us start with the \prescript to put a subscript or superscript to the following examples: left of an argument. This works well when the argu- 1. the net single premium for an n-year term insur- ment (or principal symbol) has sub- and superscripts ance payable at the end of year of death issued on all four corners, but otherwise the auxiliary sym- 1 to a person aged x is Ax:n ; bols may end up at different heights. 2. the monthly premium for an annual life Finally, various packages tailored for specific payable at the beginning of the year, starting n disciplines offer the possibility to position sub- and (12) years from now is P (n|a¨x ); superscripts on the left, for example tensor [7] for 3. the net reserve at time t for a whole tensors or mhchem [4] for isotopes. There was a previ- A payable at death is tV¯ (A¯x ). ous attempt at a LTEX package for actuarial notation All symbols are for nominal benefits of 1. [9], but lifecon does not seem to be officially dis- Actuarial notation is characterized by auxiliary tributed, either from CTAN or from anywhere else. symbols positioned in subscript and superscript on 3 Actuarial notation both sides of a principal symbol, something notori- Appendix 4 of [2] offers an excellent overview of the ously difficult to achieve consistently in LATEX. It also requires some unusual symbols not found in standard composition rules for symbols of actuarial functions. mathematics packages, like the “angle” denoting a In a nutshell, a principal symbol, say S, is combined duration n, as in n , or the overhead angle bracket with auxiliary symbols positioned in subscript or in xy used to emphasize the joint status of lives x and superscript, to the left or to the right. Schematically, y when ambiguity is possible. we thus have: II IV The package actuarialsymbol [1] provides a S (1) generic command to position all subscripts and su- I III perscripts easily and consistently around a princi- The principal symbol is in general a single letter. pal symbol, four commands to position precedence The letter may be “accented” with a bar (A¯), double numbers above and below statuses, and a number of dots (a¨) or a circle (˚e). Most commonly, there are shortcuts to ease entry of the most common actuarial alphanumeric statuses in the lower-right position functions of financial mathematics and life contingen- III . Numerals can be placed above or below the cies. The companion package actuarialangle [3], individual statuses to show the order of failure; we separate from actuarialsymbol for historical rea- will refer to these numerals as precedence numbers.

David Beauchemin and Vincent Goulet TUGboat, Volume 38 (2017), No. 3 351

Otherwise, auxiliary symbols appear lower-left I , huri is the upper right superscript IV . The princi- upper-left II and upper-right IV , in that order of pal symbol and the right subscript are required, the frequency. other arguments are optional. Symbols for benefit premiums (P ), reserves (V ) \actsymb{A}{x} Ax and amount of reduced paid-up insurance (W ), are \actsymb[n]{A}{x} nAx combined with benefit symbols unless the benefit is a 2 \actsymb[n][2]{A}{x} nAx level unit insurance payable at the end of the year of \actsymb[n][2]{A}{x}[(m)] 2A(m) death. In such cases, we have the following symbol n x structure (replace P by V or W as needed): The command \actsymb supports one more op- tional argument, for composing symbols for premi- II IV P S  (2) ums, reserves and paid-up insurance. The extended I III command 4 Additional special symbols \actsymb[hlli][huli][hPi]{hsymboli}{hlri}[huri] puts the symbol hPi outside the parentheses in the The package actuarialangle defines commands to draw two special symbols used in actuarial and fi- schematic representation (2).

nancial notation. In math mode, the command \actsymb[][][P]{\bar{A}}{x:\angln} P (A¯x:n ) \angl{hdurationi} \actsymb[k][][V]{\bar{A}}{x}[\{1\}] {1} ¯ kV (Ax) ¯ ¯ composes an angle symbol around hdurationi with \actsymb[k][][\bar{W}]{\bar{A}}{x} kW (Ax) some space (thin by default) between hdurationi and Composing actuarial symbols from scratch using the right descender. The symbol scales gracefully if \actsymb can easily get quite involved. For this the command is used outside of a first-level subscript. reason, the package defines a large number of shortcut \angl{n} \quad a_{\angl{n}} n an macros to ease entry of the most common symbols. Table 1 offers a glimpse of the available shortcuts; Commands \angln, \anglr and \anglk are short- the package documentation has the complete list. cuts for the common cases \angl{n}, \angl{r} and The definition of \actsymb is heavily inspired \angl{k}, respectively. by the code of \prescript from package mathtools The code for \angl and the underlying macro which, as reported by the author, is itself based on a were given to the second author by a colleague many posting to comp.text.tex by Michael J. Downes. years ago. The original author is unknown. The command 6 Positioning of subscripts \overanglebracket{hstatusesi} TEX adjusts the position of a subscript downward composes an angle bracket (“roof”) above hstatusesi. when a superscript is present: 2 The rule thickness and spacing relative to the statuses Ax Ax. match those of the angle symbol. The command Command \actsymb maintains this behavior, some- \group is a convenient alias for \overanglebracket. thing we believe to be a desirable feature. Therefore, entering the symbols above using the standard op- \group{xy} \quad xy A A_{\group{xy}:\angln} xy :n erators ^ and _ or with \actsymb yields the same result. 5 Construction of actuarial symbols 2 A_x \quad A_x^2 Ax Ax The package actuarialsymbol provides the generic \actsymb{A}{x} \quad 2 Ax A command \actsymb to typeset a principal symbol \actsymb{A}{x}[2] x with surrounding subscripts and superscripts. Its Furthermore, the command ensures that the left and syntax is somewhat unusual for LATEX, but it serves right subscripts, when both present, are at the same well the natural order of the building blocks of a level, something common ad hoc constructions do symbol and their relative prevalence: not provide.

\actsymb[hlli][huli]{hsymboli}{hlri}[huri] 2 {}_tA_x \quad {}_tA_x^2 tAx tAx Above, hlli identifies the auxiliary symbol in the \actsymb[t]{A}{x} \quad 2 tAx A lower left subscript position I (following the nota- \actsymb[t]{A}{x}[2] t x tion in the schematic representation (1)); huli is the Authors who would prefer a uniform subscript upper left superscript II ; hsymboli is the principal position throughout their document can load the pack- symbol S; hlri is the lower right subscript III ; and age subdepth [8].

Typesetting actuarial symbols easily and consistently with actuarialsymbol and actuarialangle 352 TUGboat, Volume 38 (2017), No. 3

Table 1: Sample of shortcuts for life table, insurance and annuity symbols. All commands accept the optional arguments hlli, huli and huri of \actsymb. Definition Example Output \lx{hagei} \lx{x} `x \dx{hagei} \dx[n]{x} ndx \px{hagei} \px[t]{x} tpx \qx{hagei} \qx[t]{x} tqx \eringx{hlri} \eringx{x:\angln} ˚ex:n

\Ax{hlri} \Ax{x:\angln} Ax:n \Ax*{hlri} \Ax*{x:\angln} A¯x:n \Ex{hlri} \Ex[n]{x} nEx

\ax{hlri} \ax{x:\angln} ax:n \ax*{hlri} \ax*{x:\angln} a¯x:n \ax**{hlri} \ax**{x:\angln} a¨x:n \aringx{hlri} \aringx{x:\angln} ˚ax:n

7 Precedence numbers For such rare circumstances, we left to the user to Precedence numbers appear above or below individ- insert a strut in the subscript to push it downward ual statuses in the right subscript III of a symbol. as needed. The commands \actsymb{A}{\rule{0pt}{2.3ex}% (m) A1 \nthtop[hlengthi]{hnumberi}{hstatusi} \nthtop{1}{x}:\angln}[(m)] x:n \nthbottom[hlengthi]{hnumberi}{hstatusi} put a precedence hnumberi above (resp. below) a This remark also applies to bottom precedence num- hstatusi, smashed so that the apparent height of the bers in inline formulas or multiline equations. status is its normal height. The optional argument hlengthi of \nthtop and \nthbottom changes the default spacing between the 1 \actsymb{A}{\nthtop{1}{x}:\angln} Ax:n number and the status for one symbol. This can also 1 be changed globally by redefining lengths mentioned \actsymb{A}{x:\nthtop{1}{\angln}} Ax:n \actsymb{A}{\nthtop{1}{x}y:% in the documentation of actuarialsymbol. 1 2 \nthtop{2}{\angln}} Axy:n The package defines shortcuts \itop, \iitop \actsymb{A}{\nthtop{3}{x}% 3 and \iiitop for first, second and third top prece- Axyz \nthbottom{1}{y}\nthbottom{2}{z}} 12 dence (and their analogues for bottom precedence). The system of precedence numbers builds on As can be seen in the third and fourth examples a macro that used to be part of actuarialangle. above, the constant spacing between the precedence As with the code for \angl, the original author is number and the status can result in numbers placed unknown. at different heights if one status contains a horizontal rule or a descender. To cope with this situation, we provide variants of the commands that always align * 8 Other functionalities precedence numbers vertically. For brevity, we have omitted some additional features \actsymb{A}{\nthtop*{1}{x}y:% 1 2 of actuarialsymbol, including macros to typeset A \nthtop*{2}{\angln}} xy:n two-letter symbols such as (IA), numerous shortcut \actsymb{A}{\nthtop{3}{x}% 3 Axyz macros and quite fancy utilities to define new ones. \nthbottom*{1}{y}\nthbottom*{2}{z}} 12 The package documentation provides all the details. The fact that top precedence numbers have zero Following [9], the package documentation also height means they will clash with a right superscript contains a Comprehensive list of life contingencies IV . symbols. The wording used here should be taken for its intended purpose, namely to acknowledge (1m) Scott Pakin’s immensely useful Comprehensive LAT X \actsymb{A}{\nthtop{1}{x}:\angln}[(m)] Ax:n E Symbol List [6]. TUGboat, Volume 38 (2017), No. 3 353

References [1] David Beauchemin and Vincent Goulet. Actuarial symbols of life contingencies and financial mathematics, 2017. ctan.org/pkg/actuarialsymbol. [2] Newton L. Bowers, Hans U. Gerber, James C. Hickman, Donald A. Jones, and Cecil J. Nesbitt. Actuarial Mathematics. Society of Actuaries, Shaumburg, IL, second edition, 1997. [3] Vincent Goulet. Actuarial angle symbol for life contingencies and financial mathematics, 2017. ctan.org/pkg/actuarialangle. [4] Martin Hensel. The mhchem Bundle, 2017. ctan.org/pkg/mhchem. [5] Morten Høgholm and Lars Madsen. The mathtools package, 2015. ctan.org/pkg/mathtools. [6] Scott Pakin. The Comprehensive LATEX Symbol List, 2015. ctan.org/pkg/comprehensive. [7] Philip G. Ratcliffe. The tensor package for LATEX2e, 2004. ctan.org/pkg/tensor. [8] Will Robertson. Unify subscript depths, 2007. ctan.org/pkg/subdepth. [9] Eddy Trivedi. Life Contingencies’ Symbols, 2004. lifecon 2.1 User Guide. [10] Henk Wolthuis. International actuarial notation. In Jozef Teugels and Bjørn Sundt, editors, Encyclopedia of Actuarial Science. Wiley, 2004. onlinelibrary.wiley.com/ book/10.1002/9780470012505.

 David Beauchemin david.beauchemin.5 (at) ulaval dot ca  Vincent Goulet Ecole´ d’actuariat Universit´eLaval Pavillon Paul-Comtois 2425, rue de l’Agriculture, Bureau 4153 Qu´ebec (QC) G1V 0A6 Canada vincent.goulet (at) act dot ulaval dot ca https://vgoulet.act.ulaval.ca