Template:Cladex/doc

This template is an eXtended version of Clade, hence the name. Both templates are for drawing branching trees with the node and base labels being clickable links. Such diagrams are especially suited to represent evolutionary trees (cladograms).

Most of the documentation is the same as the parent template, Clade, and is included below for convenience. Unless the two extra features of are needed, you are advised to use Clade.

The two extra features of are:
 * Double lines leading to a node can be produced as easily as dotted lines.
 * Brackets or bars of a chosen colour can be placed to the right of a set of leaf nodes in the cladogram, thus allowing paraphyletic groups to be identified. See . Text labels for these brackets/bars can be provided using Barlabel.

Clade and can be freely mixed, so if only some clades require the extra features, only these need be specified using.

Basic features
Use Clade unless the extra features of {tl|Cladex}} are needed.

Usage
produces

produces

produces

Note that the order of the parameters does not matter. Exactly the same output is produced by

produces

To replace a solid line leading to the Nth child with a dashed line, use |stateN=dashed.

produces

 only. To replace a single line leading to the Nth child by a double line, use |stateN=double. Notice that has only been used for the (sub)clade where the double line is wanted. The outermost clade should always be specified with Clade unless its style is altered – see below.

produces

Tips
An easy way of creating larger cladograms is to use the Newick format and proceed to edit it using a suitable text editor to produce the markup.


 * 1) Start with Newick format ((a,b),(c,d))
 * 2) Replace "(" with ""
 * 3) Edit to replace commas with pipes and numbers
 * 4) Edit clade labels if needed

Example Perl script to automate the conversion:

Using a box
You can nest the templates and use links around the text. You may use non-breaking spaces (&amp;nbsp;) to obtain spaces or to have labels that have spaces.

The entire cladogram can be placed in a box so that text flows nicely around it. You can use undefined to produce the box.

Controlling the layout of sisters
When one sister is represented as a leaf node and the other as a labelled subclade, they do not appear to be at the same level. Consider this cladogram:

Although Banksia subser. Sphaerocarpae and Banksia subser. Leptophyllae are sisters, their names are not aligned in the cladogram. If this is considered undesirable, one solution is to use a label in both cases, as shown below, which now shows the sisters at the same level.

Another 'trick' is to introduce a dummy clade. The dotted line below shows where an extra clade has been inserted:

To achieve this, instead of use

Bracketting nodes
 only. To insert a coloured 'bracket' around a set of leaf nodes which follow one another in the generated cladogram:
 * Add barbeginN=colour for the first leaf node, where N is the order of that leaf node within its clade, and colour is the required colour.
 * Add barN=colour for the remaining nodes other than the last (note that N must be the order of that node within its clade).
 * Add barendN=colour for the last node.

Either the outermost clade must be specified by Clade or if is needed there, |style=width:auto must be present.

produces

The horizontal lines can be omitted by using |barN=colour throughout. Thus the following (note the use of |style=width:auto since the outermost clade uses the extra features of ):

produces

Note that brackets or bars must only be applied to leaf nodes. In the example above, it may be tempting to write

with the expectation that the bar will be to the right of the whole of the clade containing Leaf B and Leaf C. This does not produce the required output.

Specifying colours
You can use any of the ways in which colours can be specified in HTML; e.g. the standard colour names, the three or six hex digit notations, such as #FC3 or #F3C630, or the rgb</tt> notation.

Supplying text labels
Text labels for each bracket/bar can be added using Barlabel. Accessibility guidelines require pages not to rely on colour alone, so it's particularly important to add labels if you have more than one bracket/bar and need to refer to them separately.

Debugging
If your cladogram doesn't display brackets/bars as you expected, check that:
 * You understand the numbering system for the parameters barN, etc. The N must be the same as the number of the child within its clade. Thus typically you should write |N=label for leaf|barN=colour for bar</tt>, e.g. |2= Passeridae |bar2=midnightblue</tt>.
 * You have only attempted to apply brackets/bars to leaf nodes.
 * Either the outermost clade uses Clade or if it has to use, then |style=width:auto</tt> is present.

Label length
Labels produced by |labelN=</tt>, where N</tt> is 1, 2, ..., can lead to poor layout of the resulting cladogram. (This does not apply to the text of leaves, i.e. text produced by |N=</tt>.) To avoid problems:
 * labels should be kept as short as possible, ideally a single word
 * any necessary spaces in labels should be represented as &amp;nbsp; not as actual spaces
 * line breaks (i.e.  ) should not be used.

Browser differences
Clade and Cladex work by producing hidden tables. The horizontal and vertical lines making up the tree are actually the edges of table cells. The tables are then drawn by the browser or user agent using its internal algorithms. As these differ from browser to browser, the trees produced will not look the same on all browsers.

In particular, there are two algorithms for laying out tables with empty cells, used by two groups of browsers. Safari, Chrome and Opera use one algorithm, producing cladograms like that on the left in the diagram. Internet Explorer and Firefox use another algorithm, producing cladograms like that on the right in the diagram.

No automated "fix" for these differences exists at present.

Position of brackets/bars
The bracket/bar drawing part of is probably close to the limits of what can be done using table-drawing algorithms to produce cladograms. The vertical bar is always drawn at the very right-hand edge of the hidden outermost table, which is often not how it would be drawn manually. , there is no known way round this.

Large cladograms
Clade and have some size limitations.
 * They currently allow only a maximum of 17 children per node. It may seem that this could easily be increased by editing the templates, but see the next point.
 * They will only expand a cladogram up to a certain level of complexity because the MediaWiki software limits the resources available for template expansion. The cladogram at APG_III_system has had to be broken into two parts, because Clade will not handle the entire cladogram; it runs out of the allowed resources. Any change to the template could result in large cladograms failing to display correctly.

Inclusion in books
There are many known bugs in rendering tables in the software which produces Wikipedia books; see the book tool feedback page. these result in the lines in cladograms not displaying in books.