Extension:CrossReference

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

Release status: stable

Implementation Tag
Description Adds LaTeX-style autonumbered cross references to a page
Author(s) Tore Birkeland, Stéphane GALLAND, Stanislav Pika (KvanteToretalk)
Latest version 3.0 (2010-08-15)
Database changes No
License GPL
Download here
Hooks used
ParserAfterTidy

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

Check usage and version matrix; code metrics

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.

Installation[edit | edit source]

  • Download and extract the file(s) in a directory called CrossReference in your extensions/ folder. If you're a developer and this extension is in a Git repository, then instead you should clone the repository.
  • Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/CrossReference/CrossReference.php";
  • Done! Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.

Usage[edit | edit source]

Declare Referenced Objects[edit | edit source]

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 render near the referencing object and will appear in all the references in the text.

Example:

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

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

Add Reference in Text[edit | edit source]

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 | edit source]

Subfigures, Subtables...[edit | edit source]

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>

<xrlabel/>[edit | edit source]

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.

<xr/>[edit | edit source]

Tag <xr/> takes parameters:

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

Examples[edit | edit source]

Simple Example[edit | edit source]

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>]]
</figure>
...

Subfigure Example[edit | edit source]

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">
<twocolumns>
<subfigure>
[[Image:Standard Agent LifeCycle.png|frame|<caption>Standard Agent's Life-Cycle</caption>]]
</subfigure>
<break>
<subfigure>
[[Image:Finer Agent LifeCycle.png|frame|<caption>Finer Agent's Life-Cycle</caption>]]
</subfigure>
</twocolumns>
<center><small><caption>Life Cycles of Agent</caption></small></center>
</figure>
...

Changes[edit | edit source]

  • 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.