Template:Stack

From The Kodiak Republic Wiki

Template documentation (for the above template, sometimes hidden or invisible)

Lua error in Module:TNT at line 159: Missing JsonConfig extension; Cannot load https://commons.wikimedia.org/wiki/Data:I18n/Uses TemplateStyles.tab.

This template can be used to stack images and other floating content such as infobox templates without causing problems with spacing and floating. Enter a string of images/templates as the first parameter to have them stack without generating floating errors or spacing errors. You can stack many objects from the top of a section and not force further subsections to space out.

Template:TOClimit

Usage

At its simplest:

{{stack|<objects>}}

Alternatively, using {{stack begin}} and {{stack end}}:

{{stack begin}}
<objects>
{{stack end}}

The <object> may simply be a string of wikicode for many images/templates.

Optional parameters

{{stack| <object(s)> | float=left or right | clear=true or false | margin=true or false}}

or

{{stack begin | float=left or right | clear=true or false | margin=true or false}}

where

  • float= left or right (default is right)
    This option can be used to float the stack to the left or right of the page
  • clear= true or false (default is false)
    This option can be used to force the stack to the far left or right (e.g., near an infobox).
  • margin= true or false (default is false)
    This option can be used to add a 1em margin to the left (for float right) or right (for float left).

You can also explicitly list multiple arguments:

{{stack| float=left or right | clear=true or false | margin=true or false
|1=<object(s)>
|2=<object(s)>, etc. up to 9 parameters in the current version
}}
  • This multiple argument version does include extra vertical whitespace between each (set of) <object(s)>.

Examples

To illustrate the utility of the stack templates, consider the following situation. We would like to have two right floating images at the top of the first section of our article (here, the Lipsum section), and one left floating image at the top of the second section (here, the Lorem section). To achieve this layout, without using a stack template, we could try the following code:
=====''Lipsum''=====
[[File:Simple shapes example.png|thumb|right|Example 1a]]
[[File:Simple shapes example.png|thumb|right|Example 1b]]
... text ...

=====''Lorem''=====
[[File:Simple shapes example.png|thumb|left|Example 1c]]
... text ...

=====''Ipsum''=====
... text ...
The result of this is shown in the without stack section below. Notice how the left floating image (Example 1c) is prevented from floating above the last right floating image (Example 1b). You may need to resize the width of your browser to fully appreciate the issue. To fix this problem, we can stack the two right floating images together, using the following code:
=====''Lipsum''=====
{{stack |[[File:Simple shapes example.png|thumb|right|Example 2a]] [[File:Simple shapes example.png|thumb|right|Example 2b]]}}
... text ...

=====''Lorem''=====
[[File:Simple shapes example.png|thumb|left|Example 2c]]
... text ...

=====''Ipsum''=====
... text ...
The result of this is shown in the with stack section below. Notice how by adding this stack template, the left floating image (Example 2c) can now float higher and is not blocked from floating higher than the top of the last right floating image (Example 2b).

Without {{stack}}

Lipsum
Example 1a
Example 1b

Template:Str left

Lorem
Example 1c

Template:Lipsum

Ipsum

Template:Lipsum

Template:Lipsum

With {{stack}}


Lipsum
Example 2a
Example 2b

Template:Str left

Lorem
Example 2c

Template:Lipsum

Ipsum

Template:Lipsum

Template:Lipsum

With {{stack begin}} and {{stack end}}

Lipsum with second table wider

Template:Stack begin

Sample table 1
Example 1a
Example 1b
Sample wider table 2
Example 2a
Example 2b

Template:Stack end Template:Lipsum

Lorem
Sample table 3
Example 3a

Template:Lipsum

Ipsum

Template:Lipsum

Template:Lipsum

Lipsum with first table wider

Template:Stack begin

Sample wider table 1
Example 1a
Example 1b
Sample table 2
Example 2a
Example 2b

Template:Stack end Template:Lipsum

Lorem
Sample table 3
Example 3a

Template:Lipsum

Ipsum

Template:Lipsum

Template:Lipsum

More examples

{{Stack}} can also be used to float one or more images across a page.

Simple shapes example.png
Simple shapes example.png
{{stack|[[File:Simple shapes example.png|80px]]}}
{{stack|[[File:Simple shapes example.png|120px]]}}

It might take some experience to learn how the box area floats, in combination with various images or wikitables on a page. {{Stack}}'s operation is very quick, as it uses an HTML <table> to achieve its effects.

Floating portal boxes

{{Stack}} can be used to float a portal box beside an infobox (or other right-aligned item) when other methods might not work as anticipated.

Infoboxline 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
Test image

This is a wikitable serving as a typical left-aligned table. The overlap on left-aligned tables had been a frequent problem when other boxes nearby were set to "float:right". So this is a test of how well a floating portal-box would avoid overlapping onto a left-side table.

The example here uses {{stack}} to float two portal boxes (Animals, Cats) as follows:

{{stack |{{portal|Animals}}{{portal|Cats}} }}

The two portal-boxes are stacked and floated together by both being listed as {{stack}}'s (first) parameter. Because the infobox and image were also stacked together, {{stack}} moved the two portal-boxes alongside the infobox despite they are being specified after the image.

Normally, a portal-box would be stuck below the Mona Lisa image, causing this entire text section to format further below, and causing a large text-gap of empty whitespace to appear near the infobox. There is no limit to the number of portalboxes (or Commonscat boxes) which can be listed within a {{stack}} call, such as in a stub or an article with many stacked images near the bottom. Using {{stack}} is extremely efficient, due to being a short template which uses builtin tag <table> to float the boxes.

Stack template family

Tracking category

See also


No description.

Template parameters

ParameterDescriptionTypeStatus
No parameters specified

Visit Template:Stack/doc to edit this text! (How does this work?)
Cookies help us deliver our services. By using our services, you agree to our use of cookies.
https://kodiak.wiki/wiki/Template:Stack
kodiak.wiki
CC-MAIN-2023-40
57648
application/http; msgtype=response
sha1:7XUYL46WW27QPWPM645747RQS6GE7MNS
<urn:uuid:137d0279-b1cc-43e7-8423-2ab0b81abbd1>
2023-10-03T03:16:10Z
51.222.14.30
text/html
sha1:QOCRCUJ3FTTHFFCYCRGSOYQMUAKJDWZL
<urn:uuid:191012a5-759a-4eeb-a237-c8d34fb86c14>
https://kodiak.wiki/wiki/Template:Stack
response
<urn:uuid:b89310f8-540f-4ebb-bb79-fccd37777e9f>
isPartOf: CC-MAIN-2023-40
publisher: Common Crawl
description: Wide crawl of the web for September/October 2023
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-154
software: Apache Nutch 1.19 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.5-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/