Meta:Guides/Style Guide/Tables

提供: wiki
< Meta:Guides‎ | Style Guide
2018年6月29日 (金) 03:43時点におけるYamyam (トーク | 投稿記録)による版 (1版 をインポートしました)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

テンプレート:Meta:Guides/index


Tables are an appropriate way to display lots of data in a clear structured way, and can be a valid alternative to screen dumps for showing various setups.

Tables can be written either in HTML or by using the much cleaner Wiki syntax.

Standard table

{| border="1" cellpadding="2"
 |+Multiplication table
 |-
 ! × !! 1 !! 2 !! 3
 |-
 ! 1
 | 1 || 2 || 3
 |-
 ! 2
 | 2 || 4 || 6
 |-
 ! 3
 | 3 || 6 || 9
 |-
 ! 4
 | 4 || 8 || 12
 |-
 ! 5
 | 5 || 10 || 15
 |}

returns

Multiplication table
× 1 2 3
1 1 2 3
2 2 4 6
3 3 6 9
4 4 8 12
5 5 10 15

Prettytable table format

To facilitate formatting you can put the template css/prettytable in the first row of the table.

Width

You can provide the width of the table as:

a number
the table width in pixels, or
a percentage
the percentage of the width of the page holding the table
(nothing)
this will result as the table being 100% wide

Cells text alignment

You can also provide the global text alignment in the table (should be center or right, default is left), using talign.

Examples

{| {{Css/prettytable|50}}
| 1 || 2 || 3 
|-
| 4 || 5 || 6 
|}

returns

1 2 3
4 5 6
{| {{Css/prettytable|50%}}
| 1 || 2 || 3 
|-
| 4 || 5 || 6 
|}

returns

1 2 3
4 5 6
{| {{Css/prettytable}}
| 1 || 2 || 3 
|-
| 4 || 5 || 6 
|}

returns

1 2 3
4 5 6
{| {{Css/prettytable|75%|talign=center}}
| 1 || 2 || 3 
|-
| 4 || 5 || 6 
|}

returns

1 2 3
4 5 6

Sortable tables

You can get a sortable table by adding

class="sortable"

in the first line of the table.

Examples:

{| class="sortable" border="1" cellpadding="2"
 |+Multiplication table
 |-
 ! × !! 1 !! 2 !! 3
 |-
 ! 1
 | 1 || 2 || 3
 |-
 ! 2
 | 2 || 4 || 6
 |-
 ! 3
 | 3 || 6 || 9
 |-
 ! 4
 | 4 || 8 || 12
 |-
 ! 5
 | 5 || 10 || 15
 |}

returns

Multiplication table
× 1 2 3
1 1 2 3
2 2 4 6
3 3 6 9
4 4 8 12
5 5 10 15
{| class="sortable" {{Css/prettytable|200}}
 |align=center | A 
 |align=center | B 
 |align=center | C 
 |-
 |align=center | 4 
 |align=center | 20 
 |align=center | 3 
 |-
 |align=center | 1 
 |align=center | 5 
 |align=center | 6 
 |-
 |align=center | 10 
 |align=center | 1 
 |align=center | -4 
 |}

returns

A B C
4 20 3
1 5 6
10 1 -4

Tables of images

As explained also in Meta:Guides/Style Guide/Images when you have a set of images that have some relation to each other, you can put them in a simple table:

{|align=center
| [[Image:Manual-volumerendering-reflection-sc0.5.png|thumb|150px| Reflection: Green, Scattering: 0.5]]
| [[Image:Manual-volumerendering-reflection-sc1.0.png|thumb|150px| Reflection: Green, Scattering: 1.0]]
| [[Image:Manual-volumerendering-reflection-sc2.0.png|thumb|150px| Reflection: Green, Scattering: 2.0]]
| [[Image:Manual-volumerendering-reflection-sc5.0.png|thumb|150px| Reflection: Green, Scattering: 5.0]]
|-
| [[Image:Manual-volumerendering-refl_g-tr_y-sc0.5.png|thumb|150px| Reflection: Green, Transmission: Yellow, Scattering: 0.5]]
| [[Image:Manual-volumerendering-refl_g-tr_y-sc1.0.png|thumb|150px| Reflection: Green, Transmission: Yellow, Scattering: 1.0]]
| [[Image:Manual-volumerendering-refl_g-tr_y-sc2.0.png|thumb|150px| Reflection: Green, Transmission: Yellow, Scattering: 2.0]]
| [[Image:Manual-volumerendering-refl_g-tr_y-sc5.0.png|thumb|150px| Reflection: Green, Transmission: Yellow, Scattering: 5.0]]
|}

returns

Reflection: Green, Scattering: 0.5
Reflection: Green, Scattering: 1.0
Reflection: Green, Scattering: 2.0
Reflection: Green, Scattering: 5.0
Reflection: Green, Transmission: Yellow, Scattering: 0.5
Reflection: Green, Transmission: Yellow, Scattering: 1.0
Reflection: Green, Transmission: Yellow, Scattering: 2.0
Reflection: Green, Transmission: Yellow, Scattering: 5.0

See also

Read the official documentation about tables.