PPTX
Equations and Symbols
Add mathematical equations and special symbols to slides
You can include mathematical equations and special symbols in your presentations.
Equations in Text Runs
Use Unicode characters and special formatting to represent equations:
import { Shape, Paragraph, TextRun } from "@office-open/pptx";
new Shape({
x: 1,
y: 1,
width: 8,
height: 3,
paragraphs: [
new Paragraph({
children: [
new TextRun({ text: "E = mc", fontSize: 28 }),
new TextRun({ text: "²", fontSize: 20, superScript: true }),
],
}),
new Paragraph({
children: [
new TextRun({ text: "H", fontSize: 28 }),
new TextRun({ text: "2", fontSize: 20, subScript: true }),
new TextRun({ text: "O", fontSize: 28 }),
],
}),
],
});
Superscript and Subscript
new TextRun({ text: "x", fontSize: 24 });
new TextRun({ text: "2", fontSize: 16, superScript: true }); // x²
new TextRun({ text: "n", fontSize: 16, subScript: true }); // Subscript
Common Math Symbols (Unicode)
new TextRun({ text: "π", fontSize: 24 }); // pi
new TextRun({ text: "Σ", fontSize: 24 }); // Sigma (sum)
new TextRun({ text: "∫", fontSize: 24 }); // Integral
new TextRun({ text: "√", fontSize: 24 }); // Square root
new TextRun({ text: "±", fontSize: 24 }); // Plus-minus
new TextRun({ text: "≠", fontSize: 24 }); // Not equal
new TextRun({ text: "≤", fontSize: 24 }); // Less than or equal
new TextRun({ text: "≥", fontSize: 24 }); // Greater than or equal
new TextRun({ text: "→", fontSize: 24 }); // Right arrow
new TextRun({ text: "×", fontSize: 24 }); // Multiplication
new TextRun({ text: "÷", fontSize: 24 }); // Division
new TextRun({ text: "∞", fontSize: 24 }); // Infinity
Complex Equation Layout
Build multi-line equations using multiple paragraphs:
new Shape({
x: 1,
y: 1,
width: 8,
height: 4,
paragraphs: [
new Paragraph({
alignment: "center",
children: [new TextRun({ text: "Quadratic Formula", fontSize: 18, bold: true })],
}),
new Paragraph({
alignment: "center",
children: [
new TextRun({ text: "x = (-b ± √(b", fontSize: 24 }),
new TextRun({ text: "2", fontSize: 16, superScript: true }),
new TextRun({ text: " - 4ac)) / 2a", fontSize: 24 }),
],
}),
],
});
Tips
- Use
superScript: truefor exponents andsubScript: truefor subscripts. - Unicode math symbols render correctly in most presentation viewers.
- For complex mathematical expressions, consider using an image of the equation rendered from LaTeX.