From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png

Release status:Extension status stable

ImplementationTemplate:Extension#type Tag
DescriptionTemplate:Extension#description Adds LaTeX-style autonumbered cross references to a page
Author(s)Template:Extension#username Tore Birkeland, St├ęphane GALLAND, Stanislav Pika (KvanteToretalk)
Latest versionTemplate:Extension#version 3.0 (2010-08-15)
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license GPL
Download here
Hooks usedTemplate:Extension#hook

Translate the CrossReference extension if it is available at translatewiki.net

Check usage and version matrix.

The CrossReference extension allows to create automatically numbered cross references on a wiki page, LaTeX style. It provides tags to declare objects as referenced objects: figure, table... Then because these referenced objects have identifiers, they may be referenced somewhere in the text.


  • Download and place the file(s) in a directory called CrossReference in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/CrossReference/CrossReference.php";
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.


Declare Referenced Objects[edit]

A referenced object is an object which has an identifier, and may have a caption.

Several types of referenced objects are supported:

  • fig: a figure,
  • tab: a table,
  • eqn: an equation,
  • the: a theorem,
  • def: a definition, and
  • bib: a bibliographical reference.

Each of these types have a dedicated HTML tag to declare an object instance, except for the bibliography which is not supported by this extension:

  • <figure id="identifier"> text </figure>
  • <figtable id="identifier"> text </figtable>
  • <equation id="identifier"> text </equation>
  • <theorem id="identifier"> text </theorem>
  • <definition id="identifier"> text </definition>

In the text describing the referenced object, the tag <caption/> may enclose the caption of the object. This caption will be rendered near the referencing object and will appear in all the references in the text.


<figure id="fig:myobject">
<img src="http://www.arakhne.org/images/arakhne.jpg" title="<caption>My caption</caption>">

gives: <img src="http://www.arakhne.org/images/arakhne.jpg" title="Figure 1: My caption">

Add Reference in Text[edit]

Somewhere on the page, you can put the following to reference the element: <xr id="identifier"> text in the link </xr> where identifier is the code of the referenced object to reference. The given text is put back in the reference hyper link. If this text is not given, the default text is used (basically the object number).

Example: <xr id="fig:myobject" /> gives: "Figure [#label-fig:myobject 1]".

Advanced Usage[edit]

Subfigures, Subtables...[edit]

When a figure is the composition of a set of subfigures, CrossReference extension make you able to define a number and caption for each subfigure.

The inner components must be enclosed by a tag which is corresponding to the enclosing components, ie. subfigure in a figure, subfigtable in a figtable... The inner tags do not take parameter:

  • <subfigure> text </subfigure>
  • <subfigtable> text </subfigtable>
  • <subequation> text </subequation>
  • <subtheorem> text </subtheorem>
  • <subdefinition> text </subdefinition>


All the referenced object declarations are wrappers to the tag <xrlabel/>. This tag supports several parameters:

  • id="...": the identifier of the referenced object;
  • group="...": the type of the referenced object, one of the types describes before;
  • shownumber: if present, display the object number between parenthesis (for backward compatibility with the original CrossReference extension);
  • noblock: if present, do not output the HTML
    tags which are dedicated to referenced objects;
  • noautocaption: if present, do not apply default caption formatter on the given caption.


Tag <xr/> takes parameters:

  • id="...": the identifier of the referenced object;
  • nolink: if present, do not output the hyperlink.


Simple Example[edit]

The following text is taken from Janus website:

All organizations, groups, roles and agents required to implement this example are shown in <xr id="fig:Market_Organization"/>.
As presented in <xr id="fig:Market_Organization"/>, in this example, we use three groups: g0 g1 and g3, one for each organization.
<figure id="fig:Market_Organization">
 [[File:ContractNet.png|thumb|600px|<caption>The organizations and groups of a market-like community in Janus</caption>]]

Subfigure Example[edit]

The following text is taken from Janus website:

Figure <xr id="fig:Agent_LifeCycle#1"/> illustrates the standard agent's life-cycle.
Figure <xr id="fig:Agent_LifeCycle#2"/> illustrates the finer agent's life-cyle, 
<figure id="fig:Agent_Life_Cycle">
[[Image:Standard Agent LifeCycle.png|frame|<caption>Standard Agent's Life-Cycle</caption>]]
[[Image:Finer Agent LifeCycle.png|frame|<caption>Finer Agent's Life-Cycle</caption>]]
<center><small><caption>Life Cycles of Agent</caption></small></center>


  • 3.0 (2010-08-15)
    • Add comments for translation contributors.
    • Move translations in subdirectory i18n.
    • Add French, Norwegian and Russian translations.
  • 2.0 (2010-08-03)
    • Add support for subfigures, subtables...
  • 1.1 (2010-08-03)
    • Internal caches are no more clear to avoid reference loose.
  • 1.0 (2010-08-02)
    • Complete Refund of the source code.
    • Add more supported tags.
    • Add parameters to tags.
  • 1.0-beta (2009-08-03)
    • First public release on Mediawiki website.