OPF
SpecDefinition referenceView source

Caption

A caption for an image, chart, table or video payload. A string or TextRun[] is the caption text placed below the media; object form adds the position and alignment.

Metadata

Definition
#/$defs/Caption
Form
3 alternative forms (oneOf)
Source
spec/schemas/opf.schema.json

Field index

This definition uses the forms or value constraints below.

oneOf 1 · string

Exact constraints for oneOf 1
oneOf 1 schema
{
  "type": "string"
}

oneOf 2 · array<ref:TextRun>

Exact constraints for oneOf 2
oneOf 2 schema
{
  "type": "array",
  "items": {
    "$ref": "#/$defs/TextRun"
  }
}

oneOf 3 · object

FieldTypeReq.DefaultDescription
textstring | array<ref:TextRun>yes—Caption text: a string or TextRun[] for inline rich text.
positionenum——Where the caption band sits inside the block's region: below the media (default) or above it. Core composition reserves the band and shrinks the media by its height.
position · Allowed values
"below""above"
alignenum——Horizontal alignment of the caption text within the block. Defaults to left.
align · Allowed values
"left""center""right"

text

typestring | array<ref:TextRun>requiredyesdefault—

Caption text: a string or TextRun[] for inline rich text.

position

typeenumrequirednodefault—

Where the caption band sits inside the block's region: below the media (default) or above it. Core composition reserves the band and shrinks the media by its height.

position · Allowed values
"below""above"
Field fragment · position.json
{
  "position": "below"
}

align

typeenumrequirednodefault—

Horizontal alignment of the caption text within the block. Defaults to left.

align · Allowed values
"left""center""right"
Field fragment · align.json
{
  "align": "left"
}
Exact constraints for oneOf 3
oneOf 3 schema
{
  "type": "object",
  "required": [
    "text"
  ],
  "additionalProperties": false,
  "properties": {
    "text": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/TextRun"
          }
        }
      ],
      "description": "Caption text: a string or TextRun[] for inline rich text."
    },
    "position": {
      "type": "string",
      "enum": [
        "below",
        "above"
      ],
      "description": "Where the caption band sits inside the block's region: below the media (default) or above it. Core composition reserves the band and shrinks the media by its height."
    },
    "align": {
      "type": "string",
      "enum": [
        "left",
        "center",
        "right"
      ],
      "description": "Horizontal alignment of the caption text within the block. Defaults to left."
    }
  }
}
Complete definition constraints
Exact schema constraints
{
  "description": "A caption for an image, chart, table or video payload. A string or TextRun[] is the caption text placed below the media; object form adds the position and alignment.",
  "oneOf": [
    {
      "type": "string"
    },
    {
      "type": "array",
      "items": {
        "$ref": "#/$defs/TextRun"
      }
    },
    {
      "type": "object",
      "required": [
        "text"
      ],
      "additionalProperties": false,
      "properties": {
        "text": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/TextRun"
              }
            }
          ],
          "description": "Caption text: a string or TextRun[] for inline rich text."
        },
        "position": {
          "type": "string",
          "enum": [
            "below",
            "above"
          ],
          "description": "Where the caption band sits inside the block's region: below the media (default) or above it. Core composition reserves the band and shrinks the media by its height."
        },
        "align": {
          "type": "string",
          "enum": [
            "left",
            "center",
            "right"
          ],
          "description": "Horizontal alignment of the caption text within the block. Defaults to left."
        }
      }
    }
  ],
  "examples": [
    "Figure 1. Quarterly revenue by region",
    {
      "text": "Source: internal reporting",
      "position": "above",
      "align": "center"
    }
  ]
}