Help:Table

From The Gemology Project
Revision as of 15:03, 10 June 2012 by Tim (talk | contribs) (Table attributes)
Jump to: navigation, search

How to add or modify tables in wiki

Tables are fairly simple to create or modify in this wiki. You just start with: {| And you end with: |}

So the base code of a table is:

{|
|}

Ofcourse a table consists of horizontal rows and vertical columns.
Creating this is the easiest thing to do.

Rows are created by: |-
So the code for a table with one row is:

{|
|-
|}

A row itself contains no data, just datacells (the columns).
To create a column you type: | (just below the row |-).
Code for a table with one row and one column:

{|
|-
|
|}

This will not do much as there is no data in the column. So lets add some data to it:

{|
|-
| hey it works!
|}

Which will show as:

Hey it works!


A table is not designed to hold just one piece of data, rather more, so lets add som more data.

{|
|-
| pleochroism
| weak to moderate
|}

All I did was add another | below the previous one and it will show as a new column in that row:

pleochoism weak to moderate

Now lets add another row for more information.

{|
|-
| pleochroism
| weak to moderate
|-
| cleavage
| distinct, basal
|}

Which will show as:

pleochoism weak to moderate
cleavage distinct, basal

This doesn't look like a table, so let us add some attributes to it, like a border. This is done in the opening of the main table.

{| border=1
|-
| pleochroism
| weak to moderate
|-
| cleavage
| distinct, basal
|}

pleochoism weak to moderate
cleavage distinct, basal

For the gemstone tables (templates/flashcards) the attributes are all ready defined. You simply put in {{table}} as the attribute and you need not worry about them:

{| {{table}}
|-
| pleochroism
| weak to moderate
|-
| cleavage
| distinct, basal
|}

pleochoism weak to moderate
cleavage distinct, basal

Ofcourse we want to have a header for our table. This is done with ! just above the start of the first row.

{| {{table}}
! gem
! stone
|-
| pleochroism
| weak to moderate
|-
| cleavage
| distinct, basal
|}

gem stone
pleochoism weak to moderate
cleavage distinct, basal

That doesn't look good, so lets merge the two headers in one:

{| {{table}}
! colspan=2 | gemstone
|-
| pleochroism
| weak to moderate
|-
| cleavage
| distinct, basal
|}

gemstone
pleochoism weak to moderate
cleavage distinct, basal

As you can see, you can provide extra attributes (like colspan=2, short for column span) if you seperate the attributes and the data by an | .

Table attributes

When you want two tables to be displayed next to each other you can use the align attribute:

{|border="2" align="right" ! colspan=2 | gemstone |- | pleochoism | weak to moderate etc... |} {|border="2" align="left" ! colspan=2 | gemstone |- | pleochoism | weak to moderate etc |}


gemstone
pleochoism weak to moderate
cleavage distinct, basal
gemstone
pleochoism weak to moderate
cleavage distinct, basal



But use a <br clear="all" /> to tell everything below it to stay clear of the free space or it will creep up on you.


You can use the width attribute to define the width of the table in percentages and a second width attribute in the columns to define the width of that particular column.

{|border="2" align="right" width="45%" ! colspan=2 | gemstone |- |width="50%"| pleochoism | weak to moderate etc... |} {|border="2" align="left" width="45%" ! colspan=2 | gemstone |- |width="50%"| pleochoism | weak to moderate etc |}

Which results in:


gemstone
pleochoism weak to moderate
cleavage distinct, basal
gemstone
pleochoism weak to moderate
cleavage distinct, basal


That is how easy tables are created in wiki. You can use all HTML attributes in the wiki table aswell. For more info on tables, have a look at http://meta.wikimedia.org/wiki/Help:Table