Figure Macro

Last modified by Admin on 2024/03/04 01:01

cogTag content as an illustration and with an optional caption
Recommended
TypeJAR
CategoryMacro
Developed by

Manuel Leduc, Vincent Massol, XWiki Development Team

Active Installs0
Rating
0 Votes
LicenseGNU Lesser General Public License 2.1
Compatibility

XWiki 14.9+

Installable with the Extension Manager

Description

Equivalent of the HTML5 <figure> element. Allows to tag content as containing an illustration, with an optional caption.

Usage

Without caption:

{{figure}}
... any content here...
{{/figure}}

With caption before the illustration:

{{figure}}
{{figureCaption}}...caption content here{{/figureCaption}}

... any content here...
{{/figure}}

With caption after the illustration:

{{figure}}
... any content here...

{{figureCaption}}...caption content here{{/figureCaption}}
{{/figure}}

14.9+ 

The figure macro allows to define its type using the type parameter. Three values are allowed:

  • Automatic: (default value) The type of the figure is based on the content of the figure (i.e., if the figure contains a single table, the "table" type is used, the "figure" type is used otherwise).
  • Figure: Forces the figure to the "figure" type.
  • Table: Forces the figure to the "table" type.

15.4+ New types of figure can be added by configuration.

Examples

Type "figure":

{{figure}}
[[An image>>image:http://www.clker.com/cliparts/3/m/v/Y/E/V/small-red-apple-md.png||width="100"]]
{{/figure}}

{{figure type="figure"}}{{/figure}}

Type "table":

{{figure}}
|a|b
|c|d
{{/figure

{{figure type="table"}}{{/figure}}

Examples

Image figure

{{figure}}
[[image:macaque.jpg||alt="Macaque in the trees"]]

{{figureCaption}}A cheeky macaque, Lower Kintaganban River, Borneo. Original by [[Richard Clark>>http://www.flickr.com/photos/rclark/]]{{/figureCaption}}
{{/figure}}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque tincidunt at nunc lobortis vulputate. Phasellus tempus, urna eget commodo lacinia, sapien orci elementum nibh, ac condimentum metus quam vel mauris. Aliquam vehicula vehicula fermentum. In sodales augue eu ex accumsan tincidunt. Sed pellentesque nunc sit amet accumsan posuere. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque congue rhoncus tortor vel tincidunt. Nunc tortor nisi, efficitur non nunc vitae, semper tincidunt libero. Suspendisse diam augue, euismod quis molestie nec, consequat sollicitudin mi. Phasellus sit amet sapien ante. Suspendisse ac nulla in orci efficitur porttitor sed nec mi.

Generates:

image-example-default.png

And if you apply some custom CSS you can get:

image-example.png

Table figure

{{figure}}
|= Headcell1 |= Headcell2
| cell1 | cell2

{{figureCaption}}Table caption{{/figureCaption}}
{{/figure}}        

Inline Figure

Assuming the lemma type is added to the inline types in the Administration, defining a figure of type lemma will display it with the inline style.

inline-figures-example.png

Without a caption:

{{figure type="lemma"}}
Given two line segments whose lengths are ##a## and ##b## respectively there is a real number ##r## such that ##b=ra##.
{{/figure}}

With a caption:

{{figure type="lemma"}}
{{figureCaption}}Geometry Lemma{{/figureCaption}}

Given two line segments whose lengths are ##a## and ##b## respectively there is a real number ##r## such that ##b=ra##.
{{/figure}}

15.4+ 

Administration

Note: The automatic, figure and table types always appear first and it is not needed to declare them in the configuration.

xwiki.properties

New types can be added using the `figures.types` key, for instance:

figure.block.types=graphs,plots
figure.inline.types=lemma,proof,figure,table

Note that figure types added that way are used by default on all the wikis of the farm.

XObjects

Types can be configured locally by defining an XWiki.Figure.FigureTypesConfigurationClass XObject in the XWiki.Figure.FigureTypesConfiguration page.
XObject types are overriding the xwiki.properties ones for the current wiki.

Translations

The label of a type is first translated using the org.xwiki.rendering.macro.figure.FigureType.$type translation key. If the translation key is not found, the capitalized form of its id is used instead (e.g., lemma becomes Lemma).

Developers

Figure Type Identification

14.6+ A data-xwiki-rendering-figure-type property is added to the rendered figures. When the selected type is automatic, its value is table if the figure contains a single table, and figure otherwise. If another type is selected, its value is the id of the selected type.

Figure Style

15.4+ A data-xwiki-rendering-figure-style property is added to the rendered figures. The style value can be either block or inline and represent the presentation style of the figure.
block figures are matching the "legacy" style of figure, with an optional caption placed at the top or at the bottom of the figure.
inline figures allows to place the caption inline with the first line of the caption. In this case, the figure caption is optional, but cannot be placed at the end of the figure.
See the Administration section to know how to add new inline figures.
The figure and table style is always block and their style cannot be overridden.

Related

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager).

You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.

Dependencies

Dependencies for this extension (org.xwiki.contrib:figure-macro 15.4.2):

Tags:
    

Get Connected