Template:Table/documentation: Difference between revisions
Kate Racaza (talk | contribs) No edit summary |
Lisa Hacker (talk | contribs) No edit summary |
||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__<div style="background-color: #DBE9F4;" | __NOTOC__<div style="background-color: #DBE9F4;"> | ||
Line 20: | Line 20: | ||
==Usage== | ==Usage== | ||
To use this template, type the code '''<nowiki>{{table| | To use this template, type the code '''<nowiki>{{table|X%}}</nowiki>''' next to the table's opening brackets, where '''X%''' is the desired table width. If you do not specify a table width, the table will auto-adjust to fit the contents — this may be just right or too crowded, depending on the content. For example, below is the code for the example table shown above. | ||
<pre>{| {{table|20%}} | <pre>{| {{table|20%}} | ||
Line 37: | Line 37: | ||
Below are some examples of formatting a table. For more examples, see the tutorial at http://www.mediawiki.org/wiki/Help:Tables. | Below are some examples of formatting a table. For more examples, see the tutorial at http://www.mediawiki.org/wiki/Help:Tables. | ||
{|{{table| | {|{{table|60%}} | ||
!You Type | !You Type | ||
!You | !You GetTable | ||
|- | |- | ||
|style="text-align:left;width: 50%;"|'''Merge rows and columns''' | |style="text-align:left;width: 50%;"|'''Merge rows and columns''' |
Latest revision as of 23:40, 24 June 2015
Template Documentation
This template contains table formats that can be applied to any existing table in ReliaWiki. It does not automatically create a table for you; rather it ensures that any table where the template is transcluded into will have consistent looking borders, cell padding, header shading and text alignment. (If you don't know how to create a table, see the Notes section below.)
Here is an example of what a generic table looks like when you use this template.
Column 1 | Column 2 |
---|---|
Row 1 | 123 |
Row 2 | 456 |
Row 3 | 789 |
Usage
To use this template, type the code {{table|X%}} next to the table's opening brackets, where X% is the desired table width. If you do not specify a table width, the table will auto-adjust to fit the contents — this may be just right or too crowded, depending on the content. For example, below is the code for the example table shown above.
{| {{table|20%}} ! Column 1 ! Column 2 |- | Row 1||123 |- | Row 2||456 |- | Row 3||789 |}
Custom Formatting
Below are some examples of formatting a table. For more examples, see the tutorial at http://www.mediawiki.org/wiki/Help:Tables.
You Type | You GetTable | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merge rows and columns
{| {{table|45%}} !colspan="2"| Column 1 |- | Row 1||123 |- |rowspan="2"|Row 2||456 |- |789 |} |
| ||||||||
Change text justification
{| {{table|45%}} !Column 1 !Column 2 |-style="text-align:left;" |Row 1||123 |-style="text-align:right;" |Row 2||456 |- |Row 3 ||789 |} |
| ||||||||
Change column widths (In this example, the 70% is counted from the 60% of the table width)
{| {{table|60%}} !Column 1 !Column 2 |- |Row 1||style="width: 70%;"|123 |- |Row 2||456 |- |Row 3 ||789 |} |
| ||||||||
Add a caption
{| {{table|45%}} !Column 1 !Column 2 |- |Row 1||123 |- |Row 2||456 |- |Row 3 ||789 |+'''Table Caption''' |} |
|
Notes
You can automatically convert an Excel table into the appropriate wiki code by using the free tool at http://excel2wiki.net/index.php. To ensure that the output you get from the tool works with this template, you must remove the formatting that the tool automatically assigns to the table headers. For instance, if you copy and paste our example table into the tool, the output will be:
{| {{table}} | align="center" style="background:#f0f0f0;"|'''Column 1''' | align="center" style="background:#f0f0f0;"|'''Column 2''' |- | Row 1||123 |- | Row 2||456 |- | Row 3||789 |}
In this case, you must delete the formatting around "Column 1" and "Column 2" and replace them with exclamation marks (!). See the code shown in the Usage section to see what this looks like. In a table, an exclamation mark indicates a table header. Table headers appear in bold and are centered by default.