| 2855 | self._MathStyle.TEXTSTYLE, toks["num"], toks["den"]) |
| 2856 | |
| 2857 | def _genset(self, s: str, loc: int, toks: ParseResults) -> T.Any: |
| 2858 | annotation = toks["annotation"] |
| 2859 | body = toks["body"] |
| 2860 | thickness = self.get_state().get_current_underline_thickness() |
| 2861 | |
| 2862 | annotation.shrink() |
| 2863 | centered_annotation = HCentered([annotation]) |
| 2864 | centered_body = HCentered([body]) |
| 2865 | width = max(centered_annotation.width, centered_body.width) |
| 2866 | centered_annotation.hpack(width, 'exactly') |
| 2867 | centered_body.hpack(width, 'exactly') |
| 2868 | |
| 2869 | vgap = thickness * 3 |
| 2870 | if s[loc + 1] == "u": # \underset |
| 2871 | vlist = Vlist([ |
| 2872 | centered_body, # body |
| 2873 | Vbox(0, vgap), # space |
| 2874 | centered_annotation # annotation |
| 2875 | ]) |
| 2876 | # Shift so the body sits in the same vertical position |
| 2877 | vlist.shift_amount = centered_body.depth + centered_annotation.height + vgap |
| 2878 | else: # \overset |
| 2879 | vlist = Vlist([ |
| 2880 | centered_annotation, # annotation |
| 2881 | Vbox(0, vgap), # space |
| 2882 | centered_body # body |
| 2883 | ]) |
| 2884 | |
| 2885 | # To add horizontal gap between symbols: wrap the Vlist into |
| 2886 | # an Hlist and extend it with an Hbox(0, horizontal_gap) |
| 2887 | return vlist |
| 2888 | |
| 2889 | overset = underset = _genset |
| 2890 | |