Template:Set colours/doc: Difference between revisions
mNo edit summary |
No edit summary |
||
Line 47: | Line 47: | ||
==Use outside a table== | ==Use outside a table== | ||
The {{tl|Set colours}} template defines a series of Variables; <nowiki>{{#</nowiki>var:hue1<nowiki>}}</nowiki>, <nowiki>{{#</nowiki>var:hue2<nowiki>}}</nowiki> etc, so wherever a colour is required in a document, it can be retrieved using that variable. | The {{tl|Set colours}} template defines a series of Variables; <nowiki>{{#</nowiki>var:hue1<nowiki>}}</nowiki>, <nowiki>{{#</nowiki>var:hue2<nowiki>}}</nowiki> etc, so wherever a colour is required in a document, it can be retrieved using that variable. | ||
==Template<nowiki>:</nowiki>Set colours 2== | |||
'''{{tl|Set colours 2}}''' is almost identical to {{tl|Set colours}}, except that it defaults to black not to white. It is provided in case two sets of colours are wanted running in parallel, for example ''Set colours'' may define a cell background and ''Set colours 2'' the font colour in the cell. Its variables are <nowiki>{{#</nowiki>var:hueB1<nowiki>}}</nowiki>, <nowiki>{{#</nowiki>var:hueB2<nowiki>}}</nowiki> etc. | |||
<includeonly>[[Category:Table templates|Set colours]] | <includeonly>[[Category:Table templates|Set colours]] | ||
[[Category:Colour templates|Set colours]] | [[Category:Colour templates|Set colours]] |
Latest revision as of 21:54, 11 July 2014
Template:Set colours allows you to define a set of up to 20 colours which can then be used consistently in an article. It is designed in particular for setting background colours in tables using {{Cellset}}, but it could be used in other contexts. It allows for changes of mind: having used {{Set colours}} to define the set of colours at the beginning of the document, if one is to be changed later, you only need change the code given to that template and the colour will change at every subsequent use.
Template:Cellset gives a background colour to a cell, and it is fed its values by {{Set colours}}. {{Cellset}} cannot be used unless {{Set colours}} has been included earlier in the article.
(This is essentially the same system as {{Colwidths}} – {{Cw}}, which defines column widths.)
These are not sophisticated templates nor complicated to use.
Use in table cells
1. At the top of the page (or section) add {{Set colours}} with the Hex code for each colour you may wish to use (without the "#"). It will take up to 20 colours, so:
{{Set colours|FF0000|D0F0C0|00EF42|FE4EDA}}
- this defines four colours.
2. In each cell which is to have this background colour, use {{cellset}}, followed by a pipe character ( | ): To use the first colour, put:
{{cellset|1}}|
To use the second colour, put:
{{cellset|2}}|
- and so forth.
A cell without {{cellset}} in it will simply be white as normal.
In the above example, it can produce:
Colour 1 | Colour 2 | Colour 3 |
Colour 3 | Colour 4 | Colour 2 |
If the colour has to be changed, simply change it in {{Set colours}} and every instance of {{cellset}} or {{cellset}} will follow that change.
Named colours
The system also uses {{Colour}}, which has a small list of colours which it recognises by name: see {{Colour/doc}}.
{{Set colours|red|violet|Welsh green}}
Use with {{Cw}}
The Set colours – Cellset system is essentially the same idea as the pairing of {{Colwidths}} and {{Cw}}, and you might wish to use both in a table. However, do not use {{Cw}} in the same cell as {{Cellset}} as the former stops the latter from working: instead, have in a separate row with the {{Cw}} settings in them to fix the column widths.
Use outside a table
The {{Set colours}} template defines a series of Variables; {{#var:hue1}}, {{#var:hue2}} etc, so wherever a colour is required in a document, it can be retrieved using that variable.
Template:Set colours 2
{{Set colours 2}} is almost identical to {{Set colours}}, except that it defaults to black not to white. It is provided in case two sets of colours are wanted running in parallel, for example Set colours may define a cell background and Set colours 2 the font colour in the cell. Its variables are {{#var:hueB1}}, {{#var:hueB2}} etc.