Help:Table
This page is a how-to guide detailing a practice or process on the wiki. |
- For a basic introduction, see the Introduction to tables on Wikipedia. For style considerations, see Manual of Style/Tables, also on Wikipedia.
A table is an arrangement of columns and rows used to organize and position data. Tables can be created on wiki pages using special wikitext syntax, and there are many different styles and tricks that can be used to customise them.
Tables on finiki
The Wikipedia standard for tables uses class="wikitable"
and can get automatically generated by using the table button on the Edit toolbar, which results in:
Header text | Header text | Header text |
---|---|---|
Example | Example | Example |
Example | Example | Example |
Example | Example | Example |
The same table using the {{Table}}, which is intended is used to standardize the appearance of Excel to Wiki generated tables, results in:
Header text | Header text | Header text |
---|---|---|
Example | Example | Example |
Example | Example | Example |
Example | Example | Example |
Clearly there is an inconsistency in the format depending on which method is used. Editors are reminded to exercise careful consideration before choosing which method is used. For consistency reasons, the general guideline for finiki is to follow Wikipedia's Manual of Style. Any exceptions are covered in finiki:Manual of Style.
Centering the columns of a table
If you want to have columns centered in a table, then add style="text-align:center"
after class="wikitable"
which results in:
Header text | Header text | Header text |
---|---|---|
Example | Example | Example |
Example | Example | Example |
Example | Example | Example |
Or for aligning some specific cells left and right:
Header text | Header text | Header text |
---|---|---|
Example | Example | Example |
Example | Example | Example |
Example | Example | Example |
Sortable tables
Tables can be made sortable by adding the CSS sortable; for details see Help:Sorting. Since this can be very useful, it is wise to keep the possibilities and limitations of this feature in mind when designing a table.
Sortable wikitables look like this:
name | data | more data |
---|---|---|
cats | 273 | 53 |
dogs | 65 | 8,492 |
mice | 1,649 | 548 |
Row highlighting
class=mw-datatable
allows for row highlighting. This makes it easier to follow the data and info across a row, especially in wider tables.
See Template:Mw-datatable. Add {{mw-datatable}}
in the wikitext before the table wikitext.
Add class=mw-datatable
to the top of the table wikitext.
name | data | more data |
---|---|---|
cats | 273 | 53 |
dogs | 65 | 8,492 |
mice | 1,649 | 548 |
From Excel to a sortable wikitable
To start in Excel and end up with a sortable wikitable in finiki, follow these instructions:
- Prepare your table in MS Excel. Don't bother with any formatting: it will be lost
- Copy the relevant cells in the buffer (Ctrl-c)
- Paste the contents (Ctrl-v) in Excel to Wiki
- Delete the unneeded blank line at the end
- Unselect “format header”, click on “convert”
- Copy the converted result in the buffer (Ctrl-c) and paste it (Ctrl-v) in finiki
- Replace
{{Table}}
byclass="wikitable sortable"
, and addstyle="text-align:center"
if needed - For the first line of the table, replace
|
by!
as shown here - Voilà!
How to deal with long column titles
Use line breaks, such as in the following table:
Annualized
standard
deviation (%)Maximum
annualized
return (%)Minimum
annualized
return (%)One year rolling 5.8 29.0 -19.1 5 years rolling 2.9 4.8 -9.5 10 years rolling 2.0 3.7 -4.8 20 years rolling 0.9 1.8 -1.6
Other table tips
Tables are also helpful to format figures and notes. For example, this table aligns two figures side-by-side (from Risk and return):
{| style = "margin-left:1em;margin-right:0em;" ||[[File:Range of Annual Cdn Returns.png|451px]][[File:Range of Annual US Returns.png|451px]] |- |align = "center"|'''Figure 1. Range of Returns: 1970 - 2011'''<ref group="note">The effect of removing 1982 from the bonds return was less than 1% (US -0.6%, Cdn -0.9%).</ref><ref name="attrib">Based on data from Libra Investment Management, which is Copyright © Libra Investment Management Inc. 2005-2012. All rights reserved. Used with permission.</ref> |}
Figure 1. Range of Returns: 1970 - 2011[note 1][1] |
Here's an example to embed table notes. This table utilizes the "rowspan" and "colspan" properties (from Risk and return):
{| style="margin:auto; border="1" cellpadding="0.2px" cellspacing="0" cellpadding="4" style="border-collapse: collapse;" |+ '''Table 1. 1970 - 2011 Portfolio Returns and Risk (Hypothetical)''' |- | align = "center" rowspan = "3"| Portfolio<br>Allocation||Stocks||20%||30%||40%||50%||60%||70%||80% |- ||T.Bills||20%||15%||10%||5%||5%||5%||5% |- ||Bonds||60%||55%||50%||45%||35%||25%||15% |- |colspan = "2"| Expected Return:||10%||10%||10%||11%||11%||11%||11% |- |colspan = "2"| Max predicted loss (95%):||-1%||-2%||-3%||-3%||-5%||-6%||-7% |- |colspan = "2"| 2008 return:||-4%||-8%||-12%||-15%||-19%||-22%||-26% |- |colspan = "9"| * TSX/Composite stock returns include dividends *Three month Treasury bills *Canadian Long bonds *Asset classes are uncorrelated |}
Portfolio Allocation |
Stocks | 20% | 30% | 40% | 50% | 60% | 70% | 80% |
T.Bills | 20% | 15% | 10% | 5% | 5% | 5% | 5% | |
Bonds | 60% | 55% | 50% | 45% | 35% | 25% | 15% | |
Expected Return: | 10% | 10% | 10% | 11% | 11% | 11% | 11% | |
Max predicted loss (95%): | -1% | -2% | -3% | -3% | -5% | -6% | -7% | |
2008 return: | -4% | -8% | -12% | -15% | -19% | -22% | -26% | |
|
See also
- Help:Editing
- Help:Tables (Wikipedia)
- Help:Table/Sortable tables (Wikipedia)
Notes
- ^ The effect of removing 1982 from the bonds return was less than 1% (US -0.6%, Cdn -0.9%).
References
- ^ Based on data from Libra Investment Management, which is Copyright © Libra Investment Management Inc. 2005-2012. All rights reserved. Used with permission.
External links
- TablesGenerator.com, Generate tables in MediaWiki format