答案1
答案2
答案3
修改https://tex.stackexchange.com/a/140172/4427
\documentclass{article}
\NewDocumentCommand{\annuity}{mo}{%
\hbox{%
\vbox{
\offinterlineskip
\mathsurround=0pt
\ialign{##&\vrule##\cr
\noalign{\hrule}%
&height 1pt\cr
$\scriptstyle#1\hskip\scriptspace$&\cr
}%
}%
\IfValueT{#2}{$\scriptstyle\,#2$}%
}%
}
\begin{document}
\[
s_{\annuity{n}[i]}=\frac{(1+i)^n-1}{i}
\]
\[
s_{\annuity{n}}\quad s_{\annuity{p}}
\]
\end{document}