AddMathShape

ShapeCollection.AddMathShape method

Creates a new rectangle auto shape to host mathematical content and adds it to the end of the shape collection.

public IAutoShape AddMathShape(float x, float y, float width, float height)
ParameterTypeDescription
xSingleThe x-coordinate of the shape’s frame, in points.
ySingleThe y-coordinate of the shape’s frame, in points.
widthSingleThe width of the shape’s frame, in points.
heightSingleThe height of the shape’s frame, in points.

Return Value

The newly created IAutoShape.

Examples

The following example shows how to add Mathematical Equation in PowerPoint Presentation.

[C#]
using (Presentation pres = new Presentation())
{
   IAutoShape mathShape = pres.Slides[0].Shapes.AddMathShape(0, 0, 720, 150);
   var mathParagraph = (mathShape.TextFrame.Paragraphs[0].Portions[0] as MathPortion).MathParagraph;
   var fraction = new MathematicalText("x").Divide("y");
   mathParagraph.Add(new MathBlock(fraction));
   var mathBlock = new MathematicalText("c")
        .SetSuperscript("2")
        .Join("=")
        .Join(new MathematicalText("a").SetSuperscript("2"))
        .Join("+")
        .Join(new MathematicalText("b").SetSuperscript("2"));
    mathParagraph.Add(mathBlock);
    pres.Save("math.pptx", SaveFormat.Pptx);
}

See Also