Images, Figures and Captions

Last modified by Vincent Massol on 2026/08/30 20:43

Reference

The LaTeX exporter turns every image of an exported page into a LaTeX \includegraphics command, and it understands both of the ways XWiki gives an image or a table a caption: the Figure macro and the extended image syntax of XWiki Syntax 2.1.

Images

An image that stands alone in its paragraph is centred in the exported document; an image that sits in a line of text stays where it is. The image file itself is copied into the export package, so the exported document needs nothing from the wiki to compile.

Image Size

The width and height parameters of an image are translated as follows.

Written asExported asExample
a width in percenta fraction of \linewidthwidth=50% gives width=0.5\linewidth
a height in percenta fraction of \textheight, that is of the height of the pageheight=50% gives height=0.5\textheight
any other unitpixelswidth=100 gives width=100px

For example:

[[image:whatever||width="100"]]

is exported as:

\includegraphics[width=100px]{whatever}

Captioned Figures and Tables

Caption an image or a table with the Figure macro and the figureCaption macro inside it. The export writes a LaTeX figure environment for a figure and a table environment for a table, each holding a \caption, and an id macro placed in the caption becomes the \label that a cross-reference points at.

The type parameter of the Figure macro states the type by hand. Left out, or set to automatic, the type is inferred from the content: a figure whose content is a table alone becomes a table. Stating it by hand needs version 1.6 or later of the Numbered Figures Application where that application is used.

A caption may span several paragraphs, hold line breaks or hold a list. What that means for a list of figures is described below.

See figure {{reference figure="f1"/}}.

{{figure}}
[[image:apple.png||width=100]]

{{figureCaption}}{{id name="f1"/}}An image{{/figureCaption}}
{{/figure}}

See table {{reference figure="t1"/}}.

{{figure}}
|a|b

{{figureCaption}}{{id name="t1"/}}A table{{/figureCaption}}
{{/figure}}

{{figure type='table'}}
...
{{/figure}}

figure-macro-output.png

The extended image syntax of XWiki Syntax 2.1 carries a caption too, in the label of the image reference — [[An image>>image:apple.png]]. It produces the same captioned figure as the Figure macro.

Captions in the List of Figures and Tables

The Figures and Tables export options put a list of figures and a list of tables in the exported document. An entry of such a list is a single line, so the export flattens each caption into inline content and writes the two-part LaTeX form \caption[flattened]{full}: the bracketed version goes to the list, the braced one stays under the figure.

Flattening keeps text formatting, links, inline macros, and the content of a Raw macro whose syntax is latex/1.0 — that content is taken as it stands and is expected to be inline. It drops standalone macros, the content of a Raw macro in any other syntax, and the figure and table numbers that a numbering application puts in front of a caption. What is left is joined with spaces.

Information

It is up to you to make sure that a caption survives that conversion and still works inside a LaTeX \caption command, especially where the caption uses an inline macro or the Raw macro.

So this caption:

{{figureCaption}}{{id name="test"/}}Image **caption**.

{{raw syntax="latex/1.0"}}Raw content kept.{{/raw}}

{{raw syntax="html/4.01"}}Raw content removed.{{/raw}}

With [[//several//>>https://xwiki.org]] paragraphs {{info}}and an inline macro.{{/info}}

{{info}}standalone macro{{/info}}

* And a
* list!
{{/figureCaption}}

is exported as:

\caption[Image \textbf{caption}. Raw content kept. With \href{https://xwiki.org}{\textit{several}} paragraphs \xwikiinfoinline{and an inline macro.} And a list!]{\label{test}Image \textbf{caption}.

Raw content kept.

With \href{https://xwiki.org}{\textit{several}} paragraphs \xwikiinfoinline{and an inline macro.}

\begin{xwikiinfo}{}
standalone macro
\end{xwikiinfo}

\begin{itemize}
 \item And a
 \item list!
\end{itemize}}

The Raw macro in latex/1.0 is kept and the one in html/4.01 is gone, and the list of figures shows the bracketed part alone:

Image \textbf{caption}. Raw content kept. With \href{https://xwiki.org}{\textit{several}} paragraphs \xwikiinfoinline{and an inline macro.} And a list!

Related

Get Connected