Displaying super- and subscript

左心房为你撑大大i 提交于 2019-12-24 07:34:34

问题


I'm currently working on an UWP app which also deals with math. Therefore i parse formulae and display them as inlines in a RichTextBlock. As you can imagine, I also want to display sub- and superscription - but I haven't yet found a way to do so. I know, there is something called BaselineAlignment in WPF, but it seems that this is not supported in UWP. I'm currently also about to figure out how to best display fraction lines and roots. I've thought about building my own control for this purpose, but if somebody knows a better approach it would be nice to know. I'm gladful for any answer.


回答1:


To apply subscript and superscript to text in RichTextBlock, we can take advantage of Typography.Variants attached property. For example:

<RichTextBlock FontSize="36">
    <Paragraph FontFamily="Palatino Linotype">
        2<Run Typography.Variants="Superscript">3</Run>
        14<Run Typography.Variants="Superscript">th</Run>
    </Paragraph>

    <Paragraph FontFamily="Palatino Linotype">
        H<Run Typography.Variants="Subscript">2</Run>O
        Footnote<Run Typography.Variants="Subscript">4</Run>
    </Paragraph>
</RichTextBlock>

And the output would like:




回答2:


You could use a WebBrowser control, and just locally include one of many javascript libraries for rendering LaTex.



来源:https://stackoverflow.com/questions/42120025/displaying-super-and-subscript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!