I have created the following TemplateBox Rule.
MakeBoxes[ActuarialSurvivalProbability[x_,t_],StandardForm]:=TemplateBox[{
MakeBoxes[#,StandardForm]&/@x,
MakeBoxes[t,StandardForm]
},
"ActuarialSurvivalProbability",
DisplayFunction:>(RowBox[{
SubscriptBox[
"",
TagBox[GridBox[{{#2}},GridBoxDividers->{}],"Grid"]
],
SubscriptBox[
"p",
RowBox[{
"",
TagBox[GridBox[{#1},GridBoxDividers->{
"ColumnsIndexed"->{},
"RowsIndexed"->{1->Thickness[1]}
}],"Grid"]
}]
]
}]&),
Tooltip->"probability that atleast one of live(s) aged "<>ToString[x]<>" survives for "<>ToString[t]<>" year(s)"
]
Then I evaluate the following.
ActuarialSurvivalProbability[{x, y, z}, t]
I expect an answer like that generated from the following command:
RawBoxes@TemplateBox[{
MakeBoxes[#,StandardForm]&/@{"x","y","z"},
MakeBoxes[t,StandardForm]
},
"ActuarialSurvivalProbability",
DisplayFunction:>(RowBox[{
SubscriptBox[
"",
TagBox[GridBox[{{#2}},GridBoxDividers->{}],"Grid"]
],
SubscriptBox[
"p",
RowBox[{
"",
TagBox[GridBox[{{"x","y","z"}},GridBoxDividers->{
"ColumnsIndexed"->{},
"RowsIndexed"->{1->Thickness[1]}
}],"Grid"]
}]
]
}]&),
Tooltip->"probability that atleast one of live(s) aged "<>ToString[{"x","y","z"}]<>" survives for "<>ToString[t]<>" year(s)"
]
But instead the dynamic length of input fed to GridBox in DisplayFunction in {#1} as {"x","y","z"} is not formatting correctly.
Can someone please help me?


lastSlotvariable likelastSlot=Slot[Length@x+1]insideWithto fix the variabletin the formatting. But there is one problem if you copy this notation and evaluate it, it givesActuarialSurvivalProbability[x, y, z, t]instead of the originalActuarialSurvivalProbability[{x, y, z}, t]. Is there a way to fix this? – user13892 Dec 10 '18 at 11:54DisplayFunctionis usingRuleDelayedrather than just aRuleis it necessary? because i see the documentation using it as well. – user13892 Dec 10 '18 at 14:41DisplayFunctionconditional on the values of the input parameter sayt. So ift=1. I want it to display say without presubscript. – user13892 Dec 10 '18 at 17:25ActuarialSurvivalProbability[...]definition. – user13892 Dec 10 '18 at 22:34