Template:Class figure/doc

From testwiki
Revision as of 08:35, 25 February 2025 by imported>CalendulaAsteraceae (CSS)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Template:Documentation subpage Template:Templatestyles Template:Lua

This template is for formatting figures within books (ie. block images with captions). It is meant to be used alongside CSS classes. How figures are formatted typically differs from book to book, but are fairly consistent within a given book, making it a good application for this.

There are two versions: Template:Tl, and Template:Tl for versions that generates a span rather than a div to be used when the figure appears mid-paragraph.

Parameters

The basic usage is:

{{class figure
 |num     = 
 |image   = 
 |caption = 
}}

Many books number their figures "Fig. 1", "Fig. 2", etc, and then refer to them in the text. Template:Para creates:

  1. a prefix in the caption labeling it as "Fig. n"
  2. an anchor "Fig.n" so the figure can be linked to

<templatedata> {

   "description": "The template's full parameters are:",

"params": { "image": { "label": "image", "description": "image file, no brackets, 'File:' prefix, or size", "type": "string", "required": false, "suggested": true, "default": "Template:Missing image" }, "image-size": { "label": "image size", "description": "hardcoded image size", "type": "string", "required": false }, "image-alt": { "label": "image alt", "description": "alt for image", "type": "string", "required": false }, "num": { "label": "figure number", "description": "If the figures are numbered, the number of this figure. Creates an anchor named 'Fig.<num>'.", "type": "string", "required": false }, "caption": { "label": "caption", "description": "Caption for the figure", "type": "string", "required": false }, "caption2": { "label": "caption2", "description": "Secondary caption", "type": "string", "required": false }, "key": { "label": "key", "description": "Key explaining diagram", "type": "string", "required": false }, "float": { "label": "float", "description": "figure float to side", "type": "string", "required": false, "suggestedvalues": [ "left", "right" ] }, "anchor": { "label": "anchor", "description": "anchor without 'Fig. n' label", "type": "string", "required": false }, "class": { "label": "additional classes", "description": "Additional classes you wish to apply (for example, if the book has 2 types of figures and each has different formatting).", "type": "string", "required": false }, "style": { "label": "style", "description": "CSS style", "type": "string", "required": false } } } </templatedata>

CSS

You can target the output of this template with the CSS: Template:Tree list

Template:Tree list/end

Usage

Template:Doc example

Without an image, it will automatically display Template:Tlx Template:Doc example

Template:Doc example

Template:Doc example