xref_add
Insert a cross-reference field in a .docx that points to a caption or paragraph, with options for number, page, or text. Run field.update to fill the shown value.
Instructions
Insert a cross-reference field at an insertion point (at: p14#a1b2c3d4:20-20, or a paragraph address for its end), pointing to a caption or another body paragraph. show number (default: "Table 3" for a caption), page (a PAGEREF) or text. The target gets a hidden bookmark when it has none; run field.update afterwards to fill in the shown value. A tracked insertion; backed up and undoable (history.undo); dry_run previews. Add captions with caption.add first.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| at | Yes | Insertion point: p<n>#<fp>:<k>-<k>, or a paragraph address for its end. | |
| to | Yes | Address of the caption or heading it points at. | |
| doc | Yes | Path to the .docx. | |
| tag | No | Appended to the author. | |
| show | No | number (default): a caption's label and number, or a paragraph's number; page: the page it is on; text: the caption or paragraph text. | |
| author | No | Revision author. | |
| expect | No | Write guard: the sha256 read earlier (doc.info, or a reply's doc.sha256), e.g. {"sha256": "9f86d081…"}; a file changed since is DOC_CHANGED_ON_DISK. | |
| dry_run | No | Preview only; write nothing. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | Always true on success. | |
| op | Yes | The operation that ran. | |
| api | Yes | API version (1.0). | |
| doc | No | The document read or written: path, sha256 and paragraph count. | |
| next | Yes | Cursor for the next page (pass as cursor), or null. | |
| result | Yes | What the operation returns. | |
| warnings | Yes | Things to know about the result. |