Content deleted Content added
m bolding (ombox text) |
expand |
||
Line 45:
== 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:<!--
--><pre>
=====''Lipsum''=====
[[File:Test.png|thumb|right|Example 1a]]
[[File:Test.png|thumb|right|Example 1b]]
... text ...
=====''Lorem''=====
[[File:Test.png|thumb|left|Example 1c]]
... text ...
=====''Ipsum''=====
... text ...
</pre><!--
-->The result of this is shown in the [[#Without stack|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:<!--
--><pre>
=====''Lipsum''=====
{{stack |[[File:Test.png|thumb|right|Example 2a]] [[File:Test.png|thumb|right|Example 2b]]}}
... text ...
=====''Lorem''=====
[[File:Test.png|thumb|left|Example 2c]]
... text ...
=====''Ipsum''=====
... text ...
</pre><!--
-->The result of this is show in the [[#With stack|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).
{{clear}}
{{anchor|Without stack}}
====Without {{tlf|stack}}====
----
=====''Lipsum''=====
[[File:Test.png|thumb|right|Example 1b]]
[[File:Test.png|thumb|right|Example 2b]]
''{{lipsum}}''
=====''Lorem''=====
[[File:Test.png|thumb|left|Example 3b]]
''{{lipsum}}''
=====''Ipsum''=====
''{{lipsum}}''
''{{lipsum}}''
{{clear}}
{{anchor|With stack}}
====With {{tlf|stack}}====
----
=====''Lipsum''=====
{{stack{{#ifeq:{{{1|}}}|sandbox |/sandbox}} |[[File:Test.png|thumb|right|Example 1a]] [[File:Test.png|thumb|right|Example 2a]]}}
''{{lipsum}}''
=====''Lorem''=====
[[File:Test.png|thumb|left |Example 3a]]
''{{lipsum}}''
=====''Ipsum''=====
''{{lipsum}}''
''{{lipsum}}''
{{clear}}
====With {{tlf|stack begin}} and {{tlf|stack end}}====
----
=====''Lipsum'' with second table wider=====
{{stack begin{{#ifeq:{{{1|}}}|sandbox |/sandbox}}}}
{| class="wikitable"
! Sample table 1 </tr>
| Example 1a </tr>
| Example 1b </tr>
|}
{| class="wikitable"
! Sample wider table 2 </tr>
|Example 2a </tr>
|Example 2b </tr>
|}
{{stack end{{#ifeq:{{{1|}}}|sandbox |/sandbox}}}}
''{{lipsum}}''
=====''Lorem''=====
{| style="background:whitesmoke;"
! Sample table 3 </tr>
| Example 3a </tr>
|}
''{{lipsum}}''
=====''Ipsum''=====
''{{lipsum}}''
''{{lipsum}}''
{{clear}}
=====''Lipsum'' with first table wider=====
{{stack begin{{#ifeq:{{{1|}}}|sandbox |/sandbox}}}}
{| class="wikitable"
! Sample wider table 1 </tr>
| Example 1a </tr>
| Example 1b </tr>
|}
{| class="wikitable"
! Sample table 2 </tr>
| Example 2a </tr>
| Example 2b </tr>
|}
{{stack end{{#ifeq:{{{1|}}}|sandbox |/sandbox}}}}
''{{lipsum}}''
=====''Lorem''=====
{| style="background:whitesmoke;"
! Sample table 3 </tr>
| Example 3a </tr>
|}
''{{lipsum}}''
=====''Ipsum''=====
''{{lipsum}}''
''{{lipsum}}''
{{clear}}
====With {{tlf|stack begin}} and {{tlf|stack mid}}====
----
=====''Lipsum'' with second table wider=====
{{stack begin{{#ifeq:{{{1|}}}|sandbox |/sandbox}}}}
{| class="wikitable"
! Sample table 1 </tr>
| Example 1a </tr>
| Example 1b </tr>
|}
{{stack mid{{#ifeq:{{{1|}}}|sandbox |/sandbox}}}}
{| class="wikitable"
! Sample wider table 2 </tr>
| Example 2a </tr>
| Example 2b </tr>
|}
{{stack end{{#ifeq:{{{1|}}}|sandbox |/sandbox}}}}
''{{lipsum}}''
=====''Lorem''=====
{| style="background:whitesmoke;"
! Sample table 3 </tr>
| Example 3a </tr>
|}
''{{lipsum}}''
=====''Ipsum''=====
''{{lipsum}}''
''{{lipsum}}''
{{clear}}
=====''Lipsum'' with first table wider=====
{{stack begin{{#ifeq:{{{1|}}}|sandbox |/sandbox}}}}
{| class="wikitable"
! Sample wider table 1 </tr>
| Example 1a </tr>
| Example 1b </tr>
|}
{{stack mid{{#ifeq:{{{1|}}}|sandbox |/sandbox}}}}
{| class="wikitable"
! Sample table 2 </tr>
| Example 2a </tr>
| Example 2b </tr>
|}
{{stack end{{#ifeq:{{{1|}}}|sandbox |/sandbox}}}}
''{{lipsum}}''
=====''Lorem''=====
{| style="background:whitesmoke;"
! Sample table 3 </tr>
| Example 3a </tr>
|}
''{{lipsum}}''
=====''Ipsum''=====
''{{lipsum}}''
''{{lipsum}}''
{{clear}}
===Note===
----
''Obviously these current examples '''don't''' show any difference between with and without mid'' except for probably ''unwanted'' vertical space.
In fact, the reason for creating {{tl|stack mid}}, at least in [http://en.wikipedia.org/w/index.php?title=Colorado_River&diff=483291966&oldid=483039105 one example], was resolved by removing [[Help:Table#Tables|table style]] <code>align=right</code> from tables between {{tl|stack begin}} and {{tl|stack end}}.
However {{tlf|stack mid}} may still be useful for tables that would otherwise prefer to use the multiple argument {{tl3|stack|one|two|three...}} option, which should be identical to using {{tlf|stack begin}}, {{tlf|stack mid}} and {{tlf|stack end}} where the latter easily allows the <nowiki>{| ... |}</nowiki> [[Help:Table|table syntax]] (which must begin on the start of the line).
===More examples===
----
{{tlf|Stack}} can also be used to float one or more images across a page.
{{stack{{#ifeq:{{{1|}}}|sandbox |/sandbox}} |[[File:Test.png|80px]]}}
{{stack{{#ifeq:{{{1|}}}|sandbox |/sandbox}} |[[File:Test.png|120px]]}}
<pre style="width:25.0em;overflow:auto;">
{{stack|[[File:Test.png|80px]]}}
{{stack|[[File:Test.png|120px]]}}
</pre>
It might take some experience to learn how the box area floats, in combination with various images or [[WP:Wikitables|wikitables]] on a page. {{tlf|Stack}}'s operation is very quick, as it uses an [[HTML]] <table> to achieve its effects.
===Floating portal boxes===
----
{{tlf|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.
{| class="infobox"
| '''Infobox'''
<br/>line 1 <br />line 2 <br />line 3 <br />line 4 <br />line 5 <br />line 6 <br />line 7 <br />line 8 <br />line 9
|}
[[File:Mona Lisa, by Leonardo da Vinci, from C2RMF retouched.jpg|thumb|right|60px|Test image]]
{| class="wikitable"
|style="width:33.0em<!--(was 420px)-->;"|
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.
|}
{{stack{{#ifeq:{{{1|}}}|sandbox |/sandbox}} |{{portal|Animals}}{{portal|Cats}}}}
The example here uses {{tld|stack}} to float two portal boxes (Animals, Cats) as follows:
<pre>
{{stack |{{portal|Animals}}{{portal|Cats}} }}
</pre>
The two portal-boxes are stacked and floated together by both being listed as {{tld|stack}}'s (first) parameter. Because the infobox and image were also stacked together, {{tld|stack}} moved the two portal-boxes alongside the infobox despite their 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 {{tld|stack}} call, such as in a stub or an article with many stacked images near the bottom. Using {{tld|stack}} is extremely efficient, due to being a short template which uses builtin tag <table> to float the boxes.
== Stack template family ==
|