Help:Table
A wikitable is an arrangement of columns and rows used to organize and position data. Tables are useful, and there are many ways and tricks that can be used. By design this page covers only the basics of table usage, more extensive direction and examples are available at MediaWiki Help:Tables and Wikipedia w:Help:Table or w:Wikipedia:Manual of Style/Tables. A section on Wikisource specific formatting for tables used for typography and layout is also included here.
For a better understanding of how tables offer flexible formatting options, adjust the width of your browser window while observing the changes to the examples below. The Complex example is particularly interesting.
Wiki table markup summary
[edit]
{| |
table start |
|+ |
table caption, optional; only between table start and first table row |
|- |
table row, optional on first row -- wiki engine assumes the first row |
! |
table header cell, optional. Consecutive table header cells may be added on the same line separated by double marks (!! ) or start on new lines, each with its own single mark (! ).
|
| |
table data cell, required! Consecutive table data cells may be added on the same line separated by double marks (|| ) or start on new lines, each with its own single mark (| ).
|
|} |
table end |
- The above marks must start on a new line except the double
||
and!!
for optionally adding consecutive cells to a line. However, blank spaces at the beginning of a line are ignored. - XHTML attributes. Each mark, except table end, optionally accepts one or more XHTML attributes. Attributes must be on the same line as the mark. Separate attributes from each other with a single space.
- Cells and caption (
|
or||
,!
or!!
, and|+
) hold content. So separate any attributes from content with a single pipe (|
). Cell content may follow on the same line or on following lines. - Table and row marks (
{|
and|-
) do not directly hold content. Do not add pipe (|
) after their optional attributes. If a pipe is added improperly after attributes for the table mark or row mark, the parser will delete it and any final attribute that was touching the improper pipe!
- Cells and caption (
- Content may (a) follow its cell mark on the same line after any optional XHTML attributes or (b) on lines below the cell mark. Content that uses wiki markup that itself needs to start on a new line, such as lists, headings, or nested tables, must be on its own new line.
- Escaping to insert a pipe (
|
) character into a table use the <nowiki> markup
Simple Examples
[edit]A simple table
[edit]{| | A simple table |}
As it appears in a browser:
A simple table |
A more complex example
[edit]{| class="wikitable" style="text-align:center; width:80%;" |+ Table caption |- | ! scope="col" | Header col. A ! scope="col" | Header col. B ! scope="col" | Header col. C ! scope="col" | Header col. D |- ! scope="row" | Header row 1 |cell R1-A |cell R1-B |cell R1-C |cell R1-D |- ! scope="row" | Header row 2 |cell R2-A |cell R2-B |cell R2-C |cell R2-D |- ! scope="row" | Header row 3 |cell R3-A |cell R3-B |cell R3-C |cell R3-D |- ! scope="row" | Header row 4 |cell R4-A |cell R4-B |cell R4-C |cell R4-D |}
As it appears in a browser:
Header col. A | Header col. B | Header col. C | Header col. D | |
---|---|---|---|---|
Header row 1 | cell R1-A | cell R1-B | cell R1-C | cell R1-D |
Header row 2 | cell R2-A | cell R2-B | cell R2-C | cell R2-D |
Header row 3 | cell R3-A | cell R3-B | cell R3-C | cell R3-D |
Header row 4 | cell R4-A | cell R4-B | cell R4-C | cell R4-D |
Formatting for Effect
[edit]This section address the use of tables for the recreation of printed typography and layout on Wikisource. As a general rule Wikisource does not attempt to recreate the identical formatting of the original published work. The conversion from print to electronic formatting means the work will be available on a multitude of different devices with differing screen sizes so for the most part it is counter productive to attempt to recreate to the limitations of printing on paper. At the same time, occasionally a portion of a printed work is created specifically with the limitations of paper in mind, which must be maintained in order to convey the intended meaning to the reader.
- Template:Table style lists multiple choices for formatting cells, rows and columns in tables. These shortcuts are designed specifically for use on Wikisource.
- m:Combined use of COLSPAN and ROWSPAN to force alignment, like this
Column 1 | Column 2 | Column 3 |
A | B | |
C | D | |
E | F | |
G | ||
H |
{| border="1" cellpadding="5" cellspacing="0" |- | Column 1 || Column 2 || Column 3 |- | rowspan="2"| A | colspan="2" style="text-align:center;" | B |- | C <!-- column 1 occupied by cell A --> | D |- | E | rowspan="2" colspan="2" style="text-align:center;" | F |- | G <!-- column 2+3 occupied by cell F --> |- | colspan="3" style="text-align:center;" | H |}
Simple
[edit]Good example of table used to force layout used in Wikisource From Page:Latin for beginners (1911).djvu/392
Text
[edit]Nom. Sing.—— Base —— Declension Singular Plural Nom. —— —— Gen. —— —— Dat. —— —— Ace. —— —— Abl. —— ——
Columns
[edit]
|
|
Nom. Sing.—— |
|
|
Tables
[edit]- Design notes
- 3 columns
- 9 rows
- 3 rows / 3 columns wide (
colspan="3"
), center align (style="text-align:center;"
) - 1 row / first cell empty / last 2 left align
- 5 rows / left align
- 3 rows / 3 columns wide (
- Formatting highlights
{| border="1" cellpadding="5" cellspacing="0" |- | colspan="3" style="text-align:center;"| 1 of 3 |- | colspan="3" style="text-align:center;"| 2 of 3 |- | colspan="3" style="text-align:center;"| 3 of 3 |- | || Column 2 || Column 3 |- | Column 1 || Column 2 || Column 3 |- |}
1 of 3 | ||
2 of 3 | ||
3 of 3 | ||
Column 2 | Column 3 | |
Column 1 | Column 2 | Column 3 |
Nom. Sing.—— | ||
Base —— | ||
Declension | ||
Singular | Plural | |
Nom. | _____ | _____ |
Gen. | _____ | _____ |
Dat. | _____ | _____ |
Ace. | _____ | _____ |
Abl. | _____ | _____ |
Moderate
[edit]From Page:Latin for beginners (1911).djvu/401
Text
[edit]Verb Present Infinitive Present Stem sing. plur. Indicative Mood Present Imperfect Tense sign -bā- Future Tense signs I, II, -bi-, III, IV, -ā-, -ē- Imperative Mood Present
Columns
[edit]
Verb |
|
Present Infinitive |
|
Present Stem |
|
|
Tables
[edit]- Design notes
- 4 columns
- 12 rows
- row 1 / first cell, single / second cell, single / 3&4 join
- row 2 / first 2 cells empty / last 2 singles
- row 3-11 column 1 Join (rowspan="9")
- row 3-5 join column 2 single / last 2 singles
- row 6-8 join column 2 single / last 2 singles
- row 9-11 join column 2 single / last 2 singles
- row 12 / first cell, single / column 2 single / last 2 singles
- Formatting Highlights (abbreviated version), This example does not add width or height to the empty cells, they are added in the complex example.
{| border="1" cellpadding="5" cellspacing="0" |- | Column 1 || Column 2 || colspan="2"|Column 3 & 4 |- | rowspan="3" | Row 1 - 3, Column 1 || Column 2 || Column 3 || Column 4 |- | Column 2 || Column 3 || Column 4 |- | Column 2 || Column 3 || Column 4 |- |}
Verb | Present Infinitive | Present Stem | |
sing. | plur. | ||
Indicative Mood | Present Infinitive | ||
Imperfect Tense sign -bā- | |||
Future Tense signs I, II, -bi-, III, IV, -ā-, -ē- | |||
Imperative Mood | Present |
Complex
[edit]From Page:Latin for beginners (1911).djvu/407
Text
[edit]Verb
Prin. Parts
Stems
Active Voice Passive Voice
Pres. Stem Perf. Stem Pres. Stem Perf. Stem
Indicative Indicative
Pres. Perf. Pres. Perf.
Impf. (-bā-) Plup. (-erā-) Impf. (-bā-) Plup.
Fut.(-bi- or -ā- and -ē-) Fut. Perf. (-eri-) Fut.(-bi- or -ā- and -ē-) Fut. Perf.
Imperative Imperative
Pres. Pres.
Infinitive Infinitive
Pres. Perf. Pres. Perf.
Fut. (Part. Stem)
Columns
[edit]Verb ― | |||||||||||||||||||||||||||||||||||||||
Prin. Parts | ― | ― | ― | ― | |||||||||||||||||||||||||||||||||||
Stems | ― | ― | ― | ||||||||||||||||||||||||||||||||||||
Active Voice | Passive Voice | ||||||||||||||||||||||||||||||||||||||
Pres. Stem — | Perf. Stem — | Pres. Stem — | Perf. Stem — | ||||||||||||||||||||||||||||||||||||
Indicative | Indicative | ||||||||||||||||||||||||||||||||||||||
Pres. | 1. — — | Perf. | 1. — — | Pres. | 1. — — | Perf. | 1. — — | ||||||||||||||||||||||||||||||||
2. — — | 2. — — | 2. — — | 2. — — | ||||||||||||||||||||||||||||||||||||
3. — — | 3. — — | 3. — — | 3. — — | ||||||||||||||||||||||||||||||||||||
Impf. (-bā-) |
1. — — | Plup. (-erā-) |
1. — — | Impf. (-bā-) |
1. — — | Plup. (-erā-) |
1. — — | ||||||||||||||||||||||||||||||||
2. — — | 2. — — | 2. — — | 2. — — | ||||||||||||||||||||||||||||||||||||
3. — — | 3. — — | 3. — — | 3. — — | ||||||||||||||||||||||||||||||||||||
Fut. (-bi- or -ā- and -ē-) |
1. — — | Fut. Perf. (-eri-) |
1. — — | Fut. (-bi- or -ā- and -ē-) |
1. — — | Fut. Perf. (-eri-) |
1. — — | ||||||||||||||||||||||||||||||||
2. — — | 2. — — | 2. — — | 2. — — | ||||||||||||||||||||||||||||||||||||
3. — — | 3. — — | 3. — — | 3. — — | ||||||||||||||||||||||||||||||||||||
Imperative | Imperative | ||||||||||||||||||||||||||||||||||||||
Pres. | 2. — — | Pres. | 2. — — | ||||||||||||||||||||||||||||||||||||
Infinitive | Infinitive | ||||||||||||||||||||||||||||||||||||||
Pres. | — | Perf. | — | Pres. | — | Perf. | — | ||||||||||||||||||||||||||||||||
Fut. | — | (Part. Stem) |
Tables
[edit]- Formatting Highlights (abbreviated version),
{| border="1" cellpadding="5" cellspacing="0" |- | colspan="8" |Columns 1 - 8 |- | colspan="2" | Columns 1 & 2 || colspan="2" | Columns 3 & 4 || colspan="2" | Columns 5 & 6 || colspan="2" | Columns 7 & 8 |- | colspan="4" | {{center|{{sc|Columns 1 - 4}}}} <!-- To many commands for using double pipe (||) breaks with imbedded templates --> | colspan="4" | {{center|{{sc|Columns 5 - 8}}}} |- | colspan="4" style="text-align:center;" | {{sc|Columns 1 - 4}} || colspan="4" style="text-align:center;" | {{sc|Columns 5 - 8}} <!--Formatting cell to center, double pipe (||) breaks ok --> |- style="height:2em" <!-- setting height with em makes it twice the height of the font, which as it is not set by a table parameter is the user/browser setting --> | rowspan="3"| {{sc|Column 1, row 5 - 7}} || || rowspan="3"| {{sc|Column 3, row 5 - 7}} || || rowspan="3"| {{sc|Column 5, row 5 - 7}} || || rowspan="3"| {{sc|Column 7, row 5 - 7}} || |- style="height:2em" | || || || |- style="height:2em" | width="12.5%"| || width="12.5%"| || width="12.5%"| || width="12.5%"| <!-- Give width to empty cells, only required on one row --> |}
Columns 1 - 8 | |||||||
Columns 1 & 2 | Columns 3 & 4 | Columns 5 & 6 | Columns 7 & 8 | ||||
Columns 1 - 4 |
Columns 5 - 8 | ||||||
Columns 1 - 4 | Columns 5 - 8 | ||||||
Column 1, row 5 - 7 | Column 3, row 5 - 7 | Column 5, row 5 - 7 | Column 7, row 5 - 7 | ||||
- Full Example
Verb | |||||||
Prin. Parts | |||||||
Stems | |||||||
Active Voice |
Passive Voice | ||||||
Pres. Stem | Perf. Stem | Pres. Stem | Perf. Stem | ||||
Indicative | Indicative | ||||||
Pres. | Perf. | Pres. | Perf. | ||||
Impf. (-bā-) | Plup. (-erā-) | Impf. (-bā-) | Plup. | ||||
Fut.(-bi- or -ā- and -ē-) | Fut. Perf. (-eri-) | Fut.(-bi- or -ā- and -ē-) | Fut. Perf. | ||||
Imperative |
Imperative | ||||||
Pres. | Pres. | ||||||
Infinitive |
Infinitive | ||||||
Pres. | Perf. | Pres. | Perf. | ||||
Fut. | (Part. Stem) |
Spanning Pages
[edit]When a single table spans two printed pages, the desire is to have both pages appear correctly in both the Page: namespace, and when it's transcluded.
Use the header and the footer to close and open the tables in the page name space, when transcluded it will read as one table.
Example: Page:The Works of Lord Byron (ed. Coleridge, Prothero) - Volume 2.djvu/25 has the closing of the first page in the footer. While Page:The Works of Lord Byron (ed. Coleridge, Prothero) - Volume 2.djvu/26 has the opening of the second page in the header. Which causes it to function as one table on The Works of Lord Byron (ed. Coleridge, Prothero)/Poetry/Volume 2/Childe Harold's Pilgrimage.
See: Tables across page breaks
Adding CSS Styles
[edit]The Table Style template allows fine-grain styling of tables and table cells. For example {{ts|bl.|brd|ac|xs|}} sets a cell to have a left dotted border, a double right border, text center aligned and 69% font size.
xxx | Cell contents | yyy |