Extension Points
Reference
An extension can add to the LaTeX an export produces without owning the template that produces it. Every template exposes two UI extension points, one before its output and one after it, and what a UI extension contributes there is inserted into the exported document at that point. The shipped template stays in place and keeps whatever a later release changes in it, which is what separates an extension point from an override.
A contribution is an XWiki.UIExtensionClass object on a wiki page, or a UIExtension component, as at any other extension point.
The Points Every Template Has
| Name | Extension point id | Content is inserted |
|---|---|---|
| Before any LaTeX Template | org.xwiki.contrib.latex.*.before | before the template's output |
| After any LaTeX Template | org.xwiki.contrib.latex.*.after | after the template's output |
The * stands for the name of the template being rendered, which is the simple class name of its Block: ParagraphBlock, TableCellBlock, ImageBlock. It is the name the renderer looks the template up by, so a contribution to org.xwiki.contrib.latex.ParagraphBlock.after lands after every paragraph of the export.
The shipped templates on GitHub are the complete list of the names in play, release by release.
Content contributed at these points is inserted as plain text. It is not rendered through the LaTeX renderer, so it is neither escaped nor formatted, and a Raw macro block in it produces nothing at all. Only the five document points below render their content as LaTeX.
The Document and Preamble Points
| Name | Extension point id | Content is inserted |
|---|---|---|
| Before LaTeX XDOM Template | org.xwiki.contrib.latex.XDOM.before | at the top of the file, before \documentclass |
| Before LaTeX Preamble Template | org.xwiki.contrib.latex.Preamble.before | at the start of the preamble, before the first \usepackage |
| After LaTeX UsePackage Preamble Template | org.xwiki.contrib.latex.Preamble.usepackage.after | after the \usepackage lines the extension writes |
| After LaTeX Preamble Template | org.xwiki.contrib.latex.Preamble.after | at the end of the preamble, before \begin{document} |
| After LaTeX XDOM Template | org.xwiki.contrib.latex.XDOM.after | at the end of the body, before \end{document} |
These five are written into the XDOM and Preamble templates themselves rather than coming from the mechanism above. That is what gives Preamble, a template belonging to no Block, points of its own, and what puts the content of org.xwiki.contrib.latex.XDOM.after inside the document rather than after \end{document}, where LaTeX would ignore it.
What the Content Is
A contribution is wiki syntax, and at the five document points it is rendered as LaTeX before being inserted. Ordinary text therefore arrives escaped: a per cent sign comes out as \%, a backslash as \textbackslash{}. LaTeX that has to reach the document untouched goes in a Raw macro whose syntax is latex/1.0, which needs the Raw Macro extension installed.

The rest of the object is the usual one: Extension Point ID is the id from the tables above, and Extension Scope decides which wikis the contribution applies to.
The order Parameter
Several UI extensions can answer the same point. They are rendered in the order of their order parameter, lowest first, and one declaring no order at all is rendered last. Values that are whole numbers are compared as numbers, so 9 comes before 10; anything else is compared as text.
A Contribution in Full
Two contributions add a glossary to every export. The first, at org.xwiki.contrib.latex.Preamble.usepackage.after, loads the package and declares the entries:
{{raw syntax="latex/1.0"}}
\usepackage{glossaries}
\makeglossaries
\newglossaryentry{xdom}{name=XDOM, description={the tree a wiki page is parsed into}}
{{/raw}}The second, at org.xwiki.contrib.latex.XDOM.after, prints the glossary where the document ends:
{{raw syntax="latex/1.0"}}
\printglossaries
{{/raw}}The export then produces:
\usepackage{footnote}
\makesavenoteenv{tabular}
\makesavenoteenv{table}
\usepackage{glossaries}
\makeglossaries
\newglossaryentry{xdom}{name=XDOM, description={the tree a wiki page is parsed into}}
%% the rest of the preamble, then the exported page
\printglossaries
\end{document}