LaTeX docs
Formulas written by AI agents and scripts
AI agents and scripts can add formulas too. A formula needs only its LaTeX — no rendering, no extra data.
AI agents that edit Confluence pages — for example through Atlassian’s MCP server, the Confluence REST API or Rovo — can add LaTeX formulas. Each formula is a LaTeX element with the LaTeX source as its only required setting; the app renders it when the page is viewed, exported to PDF or Word, or opened in the editor.
Three rules for agents
- Read and write the page as HTML (or ADF), not Markdown. Confluence leaves app elements out of Markdown, for every app. An agent that reads a page as Markdown and writes it back deletes the formulas. If that happens, restore the previous version from the page history.
- Insert the LaTeX element, not
$…$. Text such as$x^2$stays plain text: the app never rewrites your pages. - Copy the snippet exactly, including the long key. Only change the LaTeX.
Snippets: HTML
Use these with Atlassian’s MCP server and other tools that write Confluence pages as HTML. The LaTeX sits in JSON, so every backslash is written twice: \frac becomes \\frac.
Block formula, on its own line:
<div data-type="extension"
data-extension-key="2d4efb9a-904c-4cf2-ac2c-f59e8154be93/94db4788-6ace-44e8-aff1-15086868c54a/static/latex-block"
data-extension-type="com.atlassian.ecosystem"
data-parameters='{"guestParams":{"latex":"\\int_{-\\infty}^{\\infty} e^{-x^2}\\,dx = \\sqrt{\\pi}"}}'>LaTeX block formula</div>
Inline formula, inside a paragraph:
<p>The energy <span data-type="inline-extension"
data-extension-key="2d4efb9a-904c-4cf2-ac2c-f59e8154be93/94db4788-6ace-44e8-aff1-15086868c54a/static/latex-inline"
data-extension-type="com.atlassian.ecosystem"
data-parameters='{"guestParams":{"latex":"E = mc^2"}}'>LaTeX inline formula</span> is conserved.</p>
Snippets: ADF (REST API)
For the Confluence REST API with the atlas_doc_format body. Block formula:
{
"type": "extension",
"attrs": {
"extensionType": "com.atlassian.ecosystem",
"extensionKey": "2d4efb9a-904c-4cf2-ac2c-f59e8154be93/94db4788-6ace-44e8-aff1-15086868c54a/static/latex-block",
"parameters": { "guestParams": { "latex": "x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}" } }
}
}
For an inline formula, use "type": "inlineExtension" inside a paragraph’s content and the key ending in static/latex-inline.
Optional settings
Add these next to latex in guestParams. Anything left out uses the default.
| Setting | Values | Default |
|---|---|---|
align | left, center, right (block formulas only) | center |
size | normal, large | normal |
Example: {"guestParams":{"latex":"e^{i\\pi} + 1 = 0","align":"left","size":"large"}}
Instructions to give your agent
Paste this into your agent’s instructions, or into a page the agent reads:
When you write math on Confluence pages, use the LaTeX app's formula elements, never $…$ text.
Read and update pages as HTML, never as Markdown: Markdown drops the formulas.
Block formula: <div data-type="extension" data-extension-key="2d4efb9a-904c-4cf2-ac2c-f59e8154be93/94db4788-6ace-44e8-aff1-15086868c54a/static/latex-block" data-extension-type="com.atlassian.ecosystem" data-parameters='{"guestParams":{"latex":"LATEX"}}'>LaTeX block formula</div>
Inline formula: <span data-type="inline-extension" data-extension-key="2d4efb9a-904c-4cf2-ac2c-f59e8154be93/94db4788-6ace-44e8-aff1-15086868c54a/static/latex-inline" data-extension-type="com.atlassian.ecosystem" data-parameters='{"guestParams":{"latex":"LATEX"}}'>LaTeX inline formula</span>
Replace LATEX with the formula, escaped for JSON (each backslash doubled).
Reading formulas
Agents that read a page as HTML see each formula’s LaTeX in data-parameters, under guestParams.latex, so they can explain, check or change it. Keep the rest of the element as it is when you update a page.
Note
A formula with a LaTeX error shows the error on the page instead of the formula, without affecting the rest of the page. Open it in the editor to see what’s wrong — see Troubleshooting.