---
title: "Render PowerPoint equations in C#"
url: https://recursiveai.org/onedocument/cookbook/render-powerpoint-equations-in-slide-output/
description: "Render native Office Math equations stored as a14:m and m:oMathPara in a PPTX slide. Export a stacked fraction to PNG or PDF in C#."
version: "1.0.0"
---

Render native PPTX equations (`a14:m` / `m:oMathPara`) to PNG with `Office.Convert`, keeping fractions stacked.

```shell
dotnet add package RecursiveAI.OneDocument.Rendering
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using RecursiveAI.OneDocument;

// fraction.pptx is in the download.
Office.Convert("fraction.pptx", "slide.png");
Console.WriteLine("Wrote slide.png");
```

Paste the code above into Program.cs of a new `dotnet new console` project and `dotnet run`, or unzip [the example](https://recursiveai.org/onedocument/cookbook/render-powerpoint-equations-in-slide-output/render-powerpoint-equations-in-slide-output.zip) and `dotnet run`.

Writes the first visible slide to `slide.png` and prints:

```text
Wrote slide.png
```

The result has `x` above `2`, with a horizontal fraction bar. This is a crop of the PNG the program writes:

![Rendered equation with x stacked over 2 and a horizontal fraction bar](https://recursiveai.org/onedocument/images/render-powerpoint-equations-in-slide-output/fraction-crop.png)

`fraction.pptx` contains one slide with a text box and no picture of the equation. Here’s the equation inside that text box’s `a:p` paragraph in `ppt/slides/slide1.xml` (namespace declarations are on the slide root):

```xml
<mc:AlternateContent>
  <mc:Choice Requires="a14">
    <a14:m>
      <m:oMathPara>
        <m:oMath>
          <m:f>
            <m:num>
              <m:r><m:t>x</m:t></m:r>
            </m:num>
            <m:den>
              <m:r><m:t>2</m:t></m:r>
            </m:den>
          </m:f>
        </m:oMath>
      </m:oMathPara>
    </a14:m>
  </mc:Choice>
  <mc:Fallback>
    <a:r><a:t>Fallback text</a:t></a:r>
  </mc:Fallback>
</mc:AlternateContent>
```

The renderer draws the equation, not the literal “Fallback text”. If your equation is on a hidden slide, the default export skips that slide.

## Variations

**Keep the equation in a PDF instead.** Replace the conversion and print lines:

```csharp
Office.Convert("fraction.pptx", "slides.pdf");
Console.WriteLine("Wrote slides.pdf");
```

```text
Wrote slides.pdf
```

The default PDF export includes all visible slides. In a tagged PDF, the renderer tags the equation as a `Formula` with its linear form as alternative text.

## Related recipes

- [Export a single PowerPoint slide to PNG in C#](https://recursiveai.org/onedocument/cookbook/render-powerpoint-slide-as-png/)
- [Convert PowerPoint to PDF in C#](https://recursiveai.org/onedocument/cookbook/convert-pptx-to-pdf/)

## The short answer

Use `Office.Convert` from `RecursiveAI.OneDocument.Rendering` to render the slide that contains the equation. For native Office Math in a PowerPoint text box, OneDocument reads the math in `a14:m` and paints it in place. Choose `.png` for the first visible slide or `.pdf` for the visible deck. You don’t need to extract the XML and draw the fraction yourself.

## What are `a14:m` and `m:oMathPara` in PPTX slide XML?

`a14:m` is the PowerPoint drawing extension that wraps native Office Math inside a slide’s text. In the sample it’s inside `mc:Choice`, the markup branch for readers that understand that extension. `m:oMathPara` is a [math paragraph](https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.linq.m.omathpara); it contains an `m:oMath` equation. A slide can also have `m:oMath` directly inside `a14:m`. In the sample, `m:f` gives the renderer the fraction structure, with separate `m:num` and `m:den` elements. The two `m:t` strings alone don’t tell you which one goes above the bar.

The [presentation rendering docs](https://recursiveai.org/onedocument/docs/presentation-rendering/#text-bodies) describe the result as one unbreakable inline box on the baseline at the run’s size and color. That’s how slide text handles it even when the wrapper contains `m:oMathPara`: the renderer places the whole box in the slide’s text flow without breaking the equation over two lines.

## Why do equations disappear or look different in exported slides?

Text extraction and rendering serve different tasks. `Office.ExtractText` returns a linear representation of native math, such as `x/2`, for text consumers. It doesn’t return the fraction’s visual layout. In a rendered slide, the math layout lays out glyphs and draws rules such as the fraction bar. The linear form in a tagged PDF is alternative text, not a replacement for what’s drawn. The [math layout docs](https://recursiveai.org/onedocument/docs/math-layout/#linear-form-alternative-text-and-text-extraction) explain when that linear form is used.

If you’re troubleshooting a missing equation, first check whether the slide is part of the export: a `.png` target only writes the first visible slide. Then check what the slide stores. An equation pasted as a screenshot is a picture, not an `a14:m` math object. An embedded object follows a different path too: OneDocument draws its saved preview if present, not the object itself. The native math path shown here doesn’t need a preview image and doesn’t draw `mc:Fallback` instead of the equation.
