Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Superscript of superscript in WPF

Tags:

c#

wpf

I have managed to make a character superscript using the following lines of code:

Paragraph p=new Paragraph();     
Span s = new Span();
s.BaselineAlignment = BaselineAlignment.Superscript;
s.Inlines.Add("2");
p.Inlines.Add(new Run("EXAMPLE 1 : Describe the behaviour of the function f(x)=(x"));
p.Inlines.Add(s);
p.Inlines.Add(new Run("-1)/(x-1) near x=1."));

But is it possible to write a superscript of a superscript? Like the one shown below:

g(x)=(1+x^2)^(1/x^2)

Here the second ^ will be superscript of the superscript. How to achieve this? Also let me know is it possible to make a program understand that x^2-1 = (x-1)(x+1), and anything similar to this equation, even the nth degree equations?

like image 565
Sameek Kundu Avatar asked May 25 '13 17:05

Sameek Kundu


2 Answers

You could combine BaselineAlignment.Superscript with Typography.Variant="superscript" like this:

<Paragraph FontFamily="Palatino Linotype">
    <Run>g(x)=(1+x</Run>
    <Run Typography.Variants="Superscript">2</Run>
    <Run>)</Run>
    <Run BaselineAlignment="Superscript">(1/x</Run>
    <Run BaselineAlignment="Superscript" Typography.Variants="Superscript">2</Run>
    <Run BaselineAlignment="Superscript">)</Run>
</Paragraph>

This will give you an output something like this: Equation

like image 84
Terje Avatar answered Sep 24 '22 22:09

Terje


This project looks promising: http://blog.noldorin.com/2010/04/rendering-tex-math-in-wpf/

Your example equation could be written almost un-modified in TeX notation. See: http://www.texrendr.com/?eqn=g(x)%3D(1%2Bx%5E2)%5E%7B(1%2Fx%5E2)%7D

like image 43
nmclean Avatar answered Sep 22 '22 22:09

nmclean