gillesberger_p
gillesberger_p

Reputation: 75

Displaying super- and subscript

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.

Upvotes: 1

Views: 565

Answers (2)

Jay Zuo
Jay Zuo

Reputation: 15758

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:
enter image description here

Upvotes: 1

Mark Cidade
Mark Cidade

Reputation: 100007

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

Upvotes: 0

Related Questions