PPTX

公式与符号

向幻灯片添加数学公式和特殊符号

你可以在演示文稿中包含数学公式和特殊符号。

文本片段中的公式

使用 Unicode 字符和 baseline 实现上标/下标:

{
  "slides": [
    {
      "children": [
        {
          "shape": {
            "x": "1.3cm",
            "y": "1.3cm",
            "width": "21.2cm",
            "height": "6.6cm",
            "textBody": {
              "children": [
                {
                  "children": [
                    { "text": "E = mc", "size": 28 },
                    { "text": "2", "size": 20, "baseline": 30000 }
                  ]
                },
                {
                  "children": [
                    { "text": "H", "size": 28 },
                    { "text": "2", "size": 20, "baseline": -25000 },
                    { "text": "O", "size": 28 }
                  ]
                }
              ]
            }
          }
        }
      ]
    }
  ]
}

上标和下标

使用 baseline 属性(单位为千分之一百分比):

{ text: "x", size: 24 };
{ text: "2", size: 16, baseline: 30000 }; // x²(上标)
{ text: "n", size: 16, baseline: -25000 }; // 下标

常用数学符号(Unicode)

{ text: "π", size: 24 }; // 圆周率
{ text: "Σ", size: 24 }; // 求和符号
{ text: "", size: 24 }; // 积分
{ text: "", size: 24 }; // 平方根
{ text: "±", size: 24 }; // 正负号
{ text: "", size: 24 }; // 不等于
{ text: "", size: 24 }; // 小于等于
{ text: "", size: 24 }; // 大于等于
{ text: "", size: 24 }; // 右箭头
{ text: "×", size: 24 }; // 乘号
{ text: "÷", size: 24 }; // 除号
{ text: "", size: 24 }; // 无穷大

复杂公式布局

使用多个段落构建多行公式:

{
  "slides": [
    {
      "children": [
        {
          "shape": {
            "x": "1.3cm",
            "y": "1.3cm",
            "width": "21.2cm",
            "height": "9.3cm",
            "textBody": {
              "children": [
                {
                  "properties": { "alignment": "CENTER" },
                  "children": [{ "text": "Quadratic Formula", "size": 18, "bold": true }]
                },
                {
                  "properties": { "alignment": "CENTER" },
                  "children": [
                    { "text": "x = (-b ± √(b", "size": 24 },
                    { "text": "2", "size": 16, "baseline": 30000 },
                    { "text": " - 4ac)) / 2a", "size": 24 }
                  ]
                }
              ]
            }
          }
        }
      ]
    }
  ]
}

提示

  • 使用 baseline: 30000 表示上标,baseline: -25000 表示下标。
  • Unicode 数学符号在大多数演示文稿查看器中都能正确渲染。
  • 对于复杂的数学表达式,建议使用从 LaTeX 渲染的公式图片。
Copyright © 2026