வார்ப்புரு:Clade/doc
{{Documentation subpage}}
 {{High-use|6000}}
 {{Lua|Module:Clade}}
 {{Uses TemplateStyles|Template:Clade/styles.css}}
 &lt;!--- PLEASE ADD METADATA TO THE &lt;includeonly&gt; SECTION AT THE END OF THIS PAGE --&gt;
 
 This template is used for drawing branching trees with the node and base labels being clickable links. Such diagrams are especially suited to represent evolutionary trees ([[cladogram]]s).
 
 ==Basic features==
 
 ===Usage===
 
 &lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
 {{clade
 |label1=Base
 |1=Node
 }}
 &lt;/syntaxhighlight&gt;
 
 produces
 {{clade
 |label1=Base
 |1=Node
 }}
 
 &lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
 {{clade
 |1={{clade
    |label1=[[Subtree1]]
    |1=Leaf1
    |label2=Subtree2
    |2=[[Leaf2]]
    }}
 }}
 &lt;/syntaxhighlight&gt;
 
 produces
 {{clade
 |1={{clade
    |label1=[[Subtree1]]&amp;nbsp;
    |1=Leaf1
    |label2=Subtree2&amp;nbsp;
    |2=[[Leaf2]]
    }}
 }}
 
 &lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
 {{clade
 |1={{clade
    |label1=Subtree1
    |1=Leaf1
    |label2=Subtree2
    |2=Leaf2
    }}
 }}
 &lt;/syntaxhighlight&gt;
 
 produces
 {{clade
 |1={{clade
    |label1=Subtree1
    |1=Leaf1
    |label2=Subtree2
    |2=Leaf2
    }}
 }}
 
 Note that the order of the parameters does not matter. Exactly the same output is produced by
 &lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
 {{clade
 |1={{clade
    |2=Leaf2
    |1=Leaf1
    |label1=Subtree1
    |label2=Subtree2
    }}
 }}
 &lt;/syntaxhighlight&gt;
 
 {{clade
 |1={{clade
    |1=Leaf1
    |2=Leaf2
    |label2=Subtree2
    |label1=Subtree1
    }}
 }}
 
 ===Technical background===
 
 The clade template has many features for customising the appearance. Using them optimally requires some understanding of how the template works. The cladogram is constructed using nested HTML tables and the lines of the cladogram are borders of the cells (&lt;code&gt;&lt;nowiki&gt;&lt;td&gt;&lt;/nowiki&gt;&lt;/code&gt; tags). Each clade template creates an HTML table with the elements show as follows:
 
 {| class=&quot;wikitable&quot; 
 ! Description
 ! Table cell structure
 ! Cladogram 
 ! Code using clade template
 |-
 | style=&quot;width:20%;&quot; |&lt;p&gt;A simple clade structure with a single child node (or leaf).&lt;/p&gt;&lt;p&gt;This is an HTML table with two rows and two columns. The cells of the righthand column are merged using the rowspan attribute.&lt;/p&gt; 
 |style=&quot;padding:50px&quot; |
 {| style=&quot;line-height:100%;border:1px dotted red;margin:1px;&quot;
 |-
 | style=&quot;border:1px dotted green;border-bottom:3px solid black;text-align:center;&quot; | labelA
 | rowspan=2 style=&quot;border:1px dotted green;padding:0.1em;&quot; |
 Leaf A
 |-
 | style=&quot;border:1px dotted green;&quot; | sublabelA
 |}
 |style=&quot;padding:20px&quot; |
 {{clade |thickness=3
 |label1=labelA
 |sublabel1=sublabelA
 |1=LeafA
 }}
 |style=&quot;padding:20px&quot; |&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
 {{clade |thickness=3
 |label1=labelA
 |sublabel1=sublabelA
 |1=LeafA
 }}&lt;/syntaxhighlight&gt;
 |-
 | style=&quot;width:20%;&quot; |&lt;p&gt;Replace LeafA with another clade structure.&lt;/p&gt;&lt;p&gt;A second HTML table is placed inside a the right-hand cell of the outer table.&lt;/p&gt;
 |style=&quot;padding:50px&quot; | 
 {| style=&quot;line-height:100%;border:1px dotted red;margin:1px;&quot;
 |-
 | style=&quot;border:1px dotted green;border-bottom:3px solid black;text-align:center;&quot; | labelA
 | rowspan=2 style=&quot;border:1px dotted green;padding:0.1em;&quot; |
 {| class=&quot;clade&quot; style=&quot;line-height:100%;border:1px dotted red;margin:1px;&quot;
 |-
 | style=&quot;border:1px dotted green;border-bottom:3px solid black;text-align:center;&quot; | label1
 | rowspan=2 style=&quot;border:1px dotted green;vertical-align:middle;padding:0 1em;&quot; |leaf1 
 |-
 | style=&quot;border:1px dotted green;border-left:3px solid black;text-align:center;&quot; | sublabel1
 |-
 | style=&quot;border:1px dotted green;border-bottom:3px solid black;border-left:3px solid black;text-align:center;&quot; | label2
 | rowspan=2 style=&quot;border:1px dotted green;vertical-align:middle;padding:0 1em;&quot; |leaf2 
 |-
 | style=&quot;border:1px dotted green;text-align:center;&quot; | sublabel2
 |}
 |-
 | style=&quot;border:1px dotted green;&quot; | sublabelA
 |}
 |style=&quot;padding:20px&quot; |
 {{clade |thickness=3
 |label1=labelA
 |sublabel1=sublabelA
 |1={{clade |thickness=3
    |label1=label1
    |sublabel1=sublabel1
    |1=leaf1
    |label2=label2
    |sublabel2=sublabel2
    |2=leaf2
    }}
 }}
 |style=&quot;padding:20px&quot; |&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
 {{clade |thickness=3
 |label1=labelA
 |sublabel1=sublabelA
 |1={{clade |thickness=3
    |label1=label1
    |sublabel1=sublabel1
    |1=leaf1
    |label2=label2
    |sublabel2=sublabel2
    |2=leaf2
    }}
 }}&lt;/syntaxhighlight&gt;
 |}
 
 ===Styling brackets and branches===
 
 The appearance of the cladogram can be customised by changing the border attributes of the HTML cell elements, using the parameters {{para|state}}, {{para|color}} and {{para|thickness}} as shown below:
 
 {| class=&quot;wikitable&quot;
 !Description
 !Template code
 !Resulting output
 |-
 | style=&quot;width:25%;vertical-align:top;&quot; | '''Styling brackets'''
 
 The thickness, colour and state (solid, dashed, etc.) of bracket lines can be changed using the &lt;code&gt;thickness=&lt;/code&gt;, &lt;code&gt;|color=&lt;/code&gt; and &lt;code&gt;|state=&lt;/code&gt; parameters.
 
 |&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
 {{clade
    |label1=Bracket styling
    |sublabel1=(no suffix)
    |style1x=background-color:#ffffee;
    |1={{Clade
       |label2=color
       |2={{Clade |color=red 
          |1=A
          |2=B                
          |3=C             
         }}
       |label1=thickness
       |1={{Clade |thickness=3
           |1=I  
           |2=J          
           |3=K             
           }}
       |label3=state
       |3={{Clade |state=dashed
          |1=X 
          |2=Y         
          |3=Z        
  
          }}
       }}
 }}
 &lt;/syntaxhighlight&gt;
 
 |
 {{clade
    |label1=Bracket styling
    |sublabel1=(no suffix)
    |style1x=background-color:#ffffee;
    |1={{Clade
       |label2=color
       |2={{Clade |color=red 
          |1=A
          |2=B                
          |3=C             
         }}
       |label1=thickness
       |1={{Clade |thickness=3
           |1=I  
           |2=J          
           |3=K             
           }}
       |label3=state
       |3={{Clade |state=dashed
          |1=X 
          |2=Y         
          |3=Z        
  
          }}
       }}
 }}
 
 |-
 | style=&quot;width:25%;vertical-align:top;&quot; |'''Styling individual branches'''
 
 The thickness, colour and state of individual branch lines can be changed using the &lt;code&gt;thicknessN=&lt;/code&gt;, &lt;code&gt;|colorN=&lt;/code&gt; and &lt;code&gt;|stateN=&lt;/code&gt; parameters, where N is the number of the branch to be styled.
 
 |&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
 {{clade
    |label1=Branch styling
    |sublabel1=(append branch number)
    |style1x=background-color:#eeeeee;
    |1={{Clade
       |label2=colorN
       |2={{Clade
          |1=black (default) |color1=black          
          |2=red             |color2=red    
          |3=blue            |color3=blue   
          |4=&amp;nbsp;#00ff00       |color4=#00ff00   
          }}
       |label1=thicknessN
       |1={{Clade
           |1=1 (default) |thickness1=1 
           |2=2           |thickness2=2 
           |3=3           |thickness3=3  
           }}
       |label3=stateN
       |3={{Clade
          |1=solid (default) |state1=solid   
          |2=dotted          |state2=dotted  
          |3=dashed          |state3=dashed 
          |4=none            |state4=none   
          |5=double          |state5=double 
          }}
       }}
 }}
 &lt;/syntaxhighlight&gt;
 
 
 |
 {{clade
    |label1=Branch styling
    |sublabel1=(append branch number)
    |style1x=background-color:#eeeeee;
    |1={{Clade
       |label2=colorN
       |2={{Clade
          |1=black (default) |color1=black          
          |2=red             |color2=red    
          |3=blue            |color3=blue   
          |4=&amp;nbsp;#00ff00       |color4=#00ff00   
          }}
       |label1=thicknessN
       |1={{Clade
           |1=1 (default) |thickness1=1 
           |2=2           |thickness2=2 
           |3=3           |thickness3=3  
           }}
       |label3=stateN
       |3={{Clade
          |1=solid (default) |state1=solid   
          |2=dotted          |state2=dotted  
          |3=dashed          |state3=dashed 
          |4=none            |state4=none   
          |5=double          |state5=double 
          }}
       }}
 }}
 |}
 
 ===Reverse clade===
 
 The cladograms can also be generated right to left using {{tl|cladeR}}, as shown below.
 
 {{clade example |code=|output=
 |code1=&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;{{cladeR |reverse=yes
 |label1=''Panthera''
 |1={{cladeR
    |1={{cladeR
       |1=snow leopard
       |2=tiger
       }}
    |2={{cladeR
       |1=jaguar
       |2={{cladeR
          |1=lion
          |2=leopard
          }}
       }}
    }}
 }}&lt;/syntaxhighlight&gt;
 |output1={{cladeR |reverse=yes
 |label1=''Panthera''
 |1={{cladeR
    |1={{cladeR
       |1=snow leopard
       |2=tiger
       }}
    |2={{cladeR
       |1=jaguar
       |2={{cladeR
          |1=lion
          |2=leopard
          }}
       }}
    }}
 }}
 }}
 
 While this has limited value in English Wikipedia, it can be useful for presenting alternative phylogenies, e.g. as in the following example:
 
 {| style=&quot;margin-left: auto; margin-right: auto; border: none;&quot;
 |{{clade
 |label1=''Panthera''
 |1={{clade
    |1={{clade
       |1=snow leopard
       |2=tiger
       }}
    |2={{clade
       |1=jaguar
       |2={{clade
          |1=lion
          |2=leopard
          }}
       }}
    }}
 }}
 |
 {{cladeR
       |label1=alternative topology
       |1={{cladeR
          |1={{cladeR
             |1={{cladeR |1=&amp;nbsp;}}
             |2={{cladeR |1=&amp;nbsp;}}          
             }}
          |label2=&amp;nbsp;
          |2={{cladeR
             |1={{cladeR
                |1=&amp;nbsp;
                |2=&amp;nbsp;
                }}
             |2={{cladeR |1=&amp;nbsp;}}
             }}
          }}   
 }}
 |}
 
 
 ==Data in Newick format==
 
 A common method of presenting phylogenetic data is to use the [[Newick format]]. Many published papers provide data in Newick format in their supplementary materials and several taxonomic and phyogenetic websites provide downloads (e.g. [[Open Tree of Life]]). These Newick strings can be used to generate cladograms in several ways.
 
 ===Newick strings as a resource===
 
 Firstly, the [[Newick format]] data can be used to generate the clade structure markup using a text editor or one of several tools. 
 {{clade gallery |align=right|cladogram1={{clade |1={{clade |1=a |2=b}} |2={{clade |1=c |2=d }} }} }}
 The phylogenetic tree shown to the right is represented by the following Newick and {{tl|Clade}} code
 * Newick format: &lt;code&gt;((a,b),(c,d))&lt;/code&gt;
 * Clade code: &lt;code&gt;&lt;nowiki&gt;{{clade |1={{clade |1=a |2=b}} |2={{clade |1=c |2=d }} }} }}&lt;/nowiki&gt;&lt;/code&gt;
 
 The manual procedure for conversion in a text editor is
 # Replace &quot;(&quot; with &lt;nowiki&gt;&quot;{{clade|&quot;&lt;/nowiki&gt;
 # Replace &quot;)&quot; with &lt;nowiki&gt;&quot;}}&quot;&lt;/nowiki&gt;
 # Edit to replace commas with pipes and numbers
 # Edit clade labels if needed
 
 Fortunately, there are a number of methods for automating this task. 
 
 # One method is to use the [[User:Jts1882/sandbox/templates/NewickConverter|NewickConverter]] template (see instructions therein).
 #Alternatively, one can easily generate required clade code by downloading the free Windows utility, 'Claded', via link at http://code.google.com/p/claded, 'Claded' allowing editing of Cladograms using a tree control.
 #Example of a Perl script to automate the conversion: 
 :::&lt;syntaxhighlight lang=&quot;perl&quot;&gt;
 use constant N=&gt;&quot;\n&quot;;
 use constant T=&gt;&quot;\t&quot;;
 
 my $tree='((a,b),(c,d));'; # get sequence
 $tree=~s/[\n\r]//g; # loose those spaces
 $tree=~ s/\:[\.\d]+//g; # loose those lengths
 while ($tree=~ m/\(/) {
 	foreach my $clade ($tree=~ m/\(([^\(\)]+)\)/g) {
 		my @branches=split /\,/,$clade;
 		s/(\t+)/$1\t/g for @branches;
 		die 'ERROR: degenerate/empty node!'.N if $#branches&lt;1;
 		$tree=~ s/\(\Q$clade\E\)/${\join('','{{clade',N,map(T.'|'.($_+1).'='.$branches[$_].N,0..$#branches),T.'}}')}/; # substitute
 	}
 	pos($tree)=0;
 }
 $tree=~s/(\t*)\t\}\}/$1\}\}/g; # lazy fix
 
 print $tree;
 &lt;/syntaxhighlight&gt;
 
 ===Using Newick strings directly===
 
 The Newick format data can also be added using the {{para|newickN}}, where N refers to the child node (as with other parameters).
 
 For instance, the following Newick string
 
 &lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;((lion,jaguar,leopard),((siberian,bengal)tiger,snow leopard))panthera&lt;/syntaxhighlight&gt;
 
 can be put in the clade code as in the following example:
 
 {{Clade example
 |align=center
 |description=
 |code=
 |output=
 |comment=
 |description1=Simple use of Newick strings
 |code1=&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;{{clade
 |label1=Label
 |1={{clade
        |label1=big cats
        |1={{clade 
           |1=clouded leopards
           |style2=background-color:#ffdddd
           |newick2=((lion,jaguar,leopard),((siberian,bengal)tiger,snow leopard))panthera
           |2=Leaf B
           }}
        }}
 }}&lt;/syntaxhighlight&gt;
 |output1={{clade
        |label1=big cats
        |1={{clade 
           |1=clouded leopards
           |style2=background-color:#ffdddd
           |newick2=((lion,jaguar,leopard),((siberian,bengal)tiger,snow leopard))panthera
           |2=Leaf B
           }}
        }}
 |comment1=
 *Note that {{para|newick2}} causes {{para|2}} to be ignored. 
 *The red shaded area shows the part of the cladogram generated from the Newick string
 
 }}
 
 The Newick format data provided [[Open Tree of Life]] and other sources typically has extraneous encoding data. This can be removed using the {{para|newickN-pattern}} and {{para|newickN-replace}} parameters which supply a Lua pattern (similar to Regex) and replacement. The following code uses Newick format data for the genus ''[[Prionailurus]]'' downloaded from using Open Tree of Life ([https://tree.opentreeoflife.org/opentree/argus/ottol@570215/Prionailurus source data]):
 &lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;{{clade
    |newick1=(Prionailurus_planiceps_ott86166,(((Prionailurus_bengalensis_chinensis_ott198595,Prionailurus_bengalensis_euptilurus_ott547362,Prionailurus_bengalensis_bengalensis_ott5557509,Prionailurus_bengalensis_rabori_ott7067613)Prionailurus_bengalensis_ott280108,Prionailurus_iriomotensis_ott418475),Prionailurus_viverrinus_ott862641),Prionailurus_rubiginosus_ott507541)Prionailurus_ott570215
    |newick1-pattern1=([%a_]*)_?(ott[%d]*)
    |newick1-replace1=''%1''
    |newick1-pattern2=Prionailurus_
    |newick1-replace2=P._
    |newick1-pattern3=bengalensis_
    |newick1-replace3=b._   
    }}
 }}&lt;/syntaxhighlight&gt;
 
 produces 
 
 {{clade
 |1={{clade
    |newick1=(Prionailurus_planiceps_ott86166,(((Prionailurus_bengalensis_chinensis_ott198595,Prionailurus_bengalensis_euptilurus_ott547362,Prionailurus_bengalensis_bengalensis_ott5557509,Prionailurus_bengalensis_rabori_ott7067613)Prionailurus_bengalensis_ott280108,Prionailurus_iriomotensis_ott418475),Prionailurus_viverrinus_ott862641),Prionailurus_rubiginosus_ott507541)Prionailurus_ott570215
    |newick1-pattern=([%a_]*)_([s?p?%.?_%u%d]*)_?(ott[%d]*)
    |newick1-replace=''%1'' %2
    |newick1-pattern2=Prionailurus_
    |newick1-replace2=P._
    |newick1-pattern3=bengalensis_
    |newick1-replace3=b._
    }}
 }}
 
 ==Using a box==
 
 You can nest the templates and use links around the text. You may use non-breaking spaces (&amp;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 {{tl|Cladogram}} to produce the box.
 {{cladogram|title=Example
 |caption=Sample of {{tl|Cladogram}}
 |clades={{clade| style=font-size:75%;line-height:75%;
     |label1=[[Neornithes]]&amp;nbsp;&amp;nbsp;
     |1={{clade
         |label1=[[Paleognathae]]
         |1=&amp;nbsp;
         |label2=&amp;nbsp;[[Neognathae]]&amp;nbsp;
         |2={{clade
             |1=Other birds
             |label1=&amp;nbsp;
             |label2=[[Galloanserae]]&amp;nbsp;
             |2={{clade
                 |1=[[Anseriformes]]
                 |label2=&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
                 |2={{clade
                     |1=[[Galliformes]]
                     |2=[[Craciformes]]
                     }}
                 }}
             }}
         }}
     }}
 }}
 &lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
 {{cladogram|title=Example
 |caption=Sample of {{tl|Cladogram}}
 |clades={{clade| style=font-size:75%;line-height:75%;
     |label1=[[Neornithes]]&amp;nbsp;&amp;nbsp;
     |1={{clade
         |label1=[[Paleognathae]]
         |1=&amp;nbsp;
         |label2=&amp;nbsp;[[Neognathae]]&amp;nbsp;
         |2={{clade
             |1=Other birds
             |label1=&amp;nbsp;
             |label2=[[Galloanserae]]&amp;nbsp;
             |2={{clade
                 |1=[[Anseriformes]]
                 |label2=&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
                 |2={{clade
                     |1=[[Galliformes]]
                     |2=[[Craciformes]]
                     }}
                 }}
             }}
         }}
     }}
 }}
 &lt;/syntaxhighlight&gt;
 
 ==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:
 {{clade
 |1={{clade
    |1=[[Banksia subser. Sphaerocarpae|''Banksia''&amp;nbsp;subser.&amp;nbsp;''Sphaerocarpae'']] (5 taxa)
    |label2=[[Banksia subser. Leptophyllae|''Banksia''&amp;nbsp;subser.&amp;nbsp;''Leptophyllae'']]
    |2={{clade
       |1=''[[Banksia telmatiaea]]''
       |2=(4 other taxa)
       }}
    }}
 }}
 Although ''Banksia''&amp;nbsp;subser.&amp;nbsp;''Sphaerocarpae'' and ''Banksia''&amp;nbsp;subser.&amp;nbsp;''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 hereafter, which now shows the sisters at the same level.
 {{clade
 |1={{clade
    |label1=[[Banksia subser. Sphaerocarpae|''Banksia''&amp;nbsp;subser.&amp;nbsp;''Sphaerocarpae'']]&lt;!--added label, moved from leaf below--&gt;
    |1=(5 taxa)
    |label2=[[Banksia subser. Leptophyllae|''Banksia''&amp;nbsp;subser.&amp;nbsp;''Leptophyllae'']]
    |2={{clade
       |1=''[[Banksia telmatiaea]]''
       |2=(4 other taxa)
       }}
    }}
 }}
 Another 'trick' is to introduce a dummy clade. The red line in the following example shows where an extra clade has been inserted:
 {{clade
 |1={{clade
    |1=[[Banksia subser. Sphaerocarpae|''Banksia''&amp;nbsp;subser.&amp;nbsp;''Sphaerocarpae'']] (5 taxa)
    |color2=red
    |2={{clade&lt;!--dummy--&gt;
       |label1=[[Banksia subser. Leptophyllae|''Banksia''&amp;nbsp;subser.&amp;nbsp;''Leptophyllae'']]&lt;!--moved from 2 to 1 in new clade--&gt;
         |1={{clade
          |1=''[[Banksia telmatiaea]]''
          |2=(4 other taxa)
          }}
       }}
    }}
 }}
 
 To achieve this, instead of
 &lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
 {{clade
  |1=Sister1
  |label2=Sister2
  |2={{clade
    |1=taxon1
    |2=taxon2}}
 }}
 &lt;/syntaxhighlight&gt;
 which displays as:
 {{clade
 |1=Sister1
  |label2=Sister2
  |2={{clade
    |1=taxon1
    |2=taxon2}}
 }}
 use
 &lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
 {{clade
  |1=Sister1
  |2={{clade &lt;!--extra dummy clade--&gt;
     |label1=Sister2
     |1={{clade
        |1=taxon1
        |2=taxon2
        }}
    }}
 }}
 &lt;/syntaxhighlight&gt;
 which displays as:
 {{clade
  |1=Sister1
  |2={{clade &lt;!--extra dummy clade--&gt;
     |label1=Sister2
     |1={{clade
        |1=taxon1
        |2=taxon2
        }}
    }}
 }}
 
 ==Bracketting and labelling nodes==
 
 ===Adding vertical bars and brackets===
 
 To insert a coloured 'bracket' around a set of leaf nodes which follow one another in the generated cladogram:
 * Add &lt;code&gt;barbeginN=''colour''&lt;/code&gt; for the first leaf node, where N is the order of that leaf node within its clade, and ''colour'' is the required colour.
 * Add &lt;code&gt;barN=''colour''&lt;/code&gt; for the remaining nodes other than the last (note that N must be the order of that node within its clade).
 * Add &lt;code&gt;barendN=''colour''&lt;/code&gt; for the last node.
 
 {{clade example |code=|output=
 |code1=&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
 {{clade|style=font-size:85%;line-height:100%;
 |1={{clade
    |1=Leaf A
    |2=Leaf B|barbegin2=green
    |3=Leaf C|bar3=green
    |4={{clade
       |1=Leaf D|barend1=green
       |2=Leaf E
       |3=Leaf F|barbegin3=purple
       |4={{clade
          |1=Leaf G&amp;nbsp;|bar1=purple
          |2=Leaf H&amp;nbsp;|barend2=purple
          }}
       }}
    }}
 }}
 &lt;/syntaxhighlight&gt;
 
 |output1=&lt;div style=&quot;padding:6em;&gt;
 {{clade|style=font-size:85%;line-height:100%;
 |1={{clade
    |1=Leaf A
    |2=Leaf B|barbegin2=green
    |3=Leaf C|bar3=green
    |4={{clade
       |1=Leaf D|barend1=green
       |2=Leaf E
       |3=Leaf F|barbegin3=purple
       |4={{clade
          |1=Leaf G&amp;nbsp;|bar1=purple
          |2=Leaf H&amp;nbsp;|barend2=purple
          }}
       }}
    }}
 }}&lt;/div&gt;
 }}
 
 Note the using of the non-breaking space (&lt;code&gt;&amp;nbsp;&lt;/code&gt;) to move the vertical bar from the leaf text. 
 
 The horizontal lines can be omitted by using &lt;code&gt;{{!}}barN=''colour''&lt;/code&gt; throughout. Thus the following produces simple vertical bars:
 
 {{clade example |code=|output=|comment=
 |code1=&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
 {{clade|style=font-size:85%;line-height:100%;
 |1=Leaf A
 |2={{clade
    |1=Leaf B|bar1=midnightblue
    |2=Leaf C|bar2=midnightblue
    }}
 |3=Leaf D|bar3=midnightblue
 }}
 &lt;/syntaxhighlight&gt;
 
 |output1=&lt;div style=&quot;padding:6em;&gt;
 {{clade|style=font-size:85%;line-height:100%;
 |1=Leaf A
 |2={{clade
    |1=Leaf&amp;nbsp;B&amp;nbsp;|bar1=midnightblue
    |2=Leaf&amp;nbsp;C&amp;nbsp;|bar2=midnightblue
    }}
 |3=Leaf D|bar3=midnightblue
 }}
 &lt;/div&gt;
 
 |comment1=
 Note that brackets or bars cane be applied internal nodes as well as leaf nodes. So the following code produces the same result.
 
 &lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
 {{clade|style=font-size:85%;line-height:100%;
 |1=Leaf A
 |bar2=midnightblue
 |2={{clade
    |1=Leaf B
    |2=Leaf C
    }}
 |3=Leaf D|bar3=midnightblue
 }}
 &lt;/syntaxhighlight&gt;
 }}
 
 ===Specifying bracket colours===
 
 You can use any of the ways in which colours can be specified in [[HTML]]; e.g. the standard [http://www.w3schools.com/html/html_colornames.asp colour names], the three or six hex digit notations, such as #FC3 or #F3C630, or the &lt;code&gt;rgb()&lt;/code&gt; notation.
 
 ===Adding text labels to brackets===
 
 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. A couple of methods are available.
 
 # Text labels for each bracket/bar can be added using {{tl|Barlabel}} (see instructions at template page). 
 # Use the {{para|grouplabelN}} parameter. This adds a label to the right of the righthand bracket or bar, as shown in the following example. The right hand column illustrates how {{para|grouplabel}} adds an HTML cell to the right of the terminal leaf.
 
 {{clade example |code=|output=|comment=Cell structure
 |code1=&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;{{clade
 |label1=labelA 
 |grouplabel1=Grouplabel&amp;nbsp;A
 |bar1=blue
 |1={{clade 
    |label1=label1
    |1=&amp;nbsp;leaf1&amp;nbsp;
    |label2=label2
    |2=&amp;nbsp;leaf2&amp;nbsp;
    }}
 }}&lt;/syntaxhighlight&gt;
 |output1={{clade
 |label1=labelA 
 |sublabel1=sublabelA
 |grouplabel1=Grouplabel&amp;nbsp;A
 |bar1=blue
 |1={{clade
    |label1=label1
    |1=&amp;nbsp;leaf1&amp;nbsp;
    |label2=label2
    |2=&amp;nbsp;leaf2&amp;nbsp;
    }}
 }}
 |comment1=
 {{{!}} style=&quot;line-height:100%;border:1px dotted red;margin:1px;&quot;
 {{!}}-
 {{!}} style=&quot;border:1px dotted green;border-bottom:3px solid black;text-align:center;&quot; {{!}} labelA
 {{!}} rowspan=2 style=&quot;border:1px dotted green;border-right:2px solid blue; padding:0.2em;&quot; {{!}}
 {{{!}} class=&quot;clade&quot; style=&quot;line-height:100%;border:1px dotted red;margin:1px;&quot;
 {{!}}-
 {{!}} style=&quot;border:1px dotted green;border-bottom:3px solid black;&quot; {{!}} label1
 {{!}} rowspan=2 style=&quot;border:1px dotted green;vertical-align:middle;padding:0 1em;&quot; {{!}}leaf1 
 {{!}}-
 {{!}} style=&quot;border:1px dotted green;border-left:3px solid black;&quot; {{!}} &amp;nbsp;
 {{!}}-
 {{!}} style=&quot;border:1px dotted green;border-bottom:3px solid black;border-left:3px solid black;&quot; {{!}} label2
 {{!}} rowspan=2 style=&quot;border:1px dotted green;vertical-align:middle;padding:0 1em;&quot; {{!}}leaf2 
 {{!}}-
 {{!}} style=&quot;border:1px dotted green;&quot; {{!}} &amp;nbsp;
 {{!}}}
 {{!}} rowspan=2 style=&quot;border:1px dotted green;padding:0.2em;&quot; {{!}} Grouplabel&amp;nbsp;A
 {{!}}-
 {{!}} style=&quot;border:1px solid green;&quot; {{!}} sublabelA
 {{!}}}
 }}
 
 In the example above grouplabel was used to label a bar marking the entire clade. It provided an alternative to labelA. However, if the bar is only applied to some terminals, {{para|grouplabelN}} can be used to mark paraphyletic groups. The following example also demonstrates the use of {{para|grouplabelstyleN}} to apply CSS styling to the grouplabel, in this case the color.
 
 {{clade example |code=|output=
 |code1=&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;{{clade
 |grouplabel1=ANA Group
 |grouplabelstyle1=color:green;
 |label1='''Angiosperms'''
 |1={{clade
    |1=[[Amborellales]]           |barbegin1=green
    |2={{clade
       |1=[[Nymphaeales]]         |bar1=green
       |2={{clade
          |1=[[Austrobaileyales]] |barend1=green
          |2=[[Mesangiosperms]]   
          }}
       }}
    }}
 }}
 &lt;/syntaxhighlight&gt;
 |output1={{clade
 |grouplabel1=ANA Group
 |grouplabelstyle1=color:green;
 |label1='''Angiosperms'''
 |1={{clade
    |1=[[Amborellales]]           |barbegin1=green
    |2={{clade
       |1=[[Nymphaeales]]         |bar1=green
       |2={{clade
          |1=[[Austrobaileyales]] |barend1=green
          |2=[[Mesangiosperms]]   
          }}
       }}
    }}
 }}
 }}
 
 The {{para|grouplabel}} parameter can be used to add multiple labels with the aid of the {{tl|clade labels}} template. This template uses absolute CSS positioning to determine the placement of the label. When applied to a {{para|grouplabel1}} parameter on the outer clade it behaves very similarly to {{tl|barlabel}}. A simple example to label two groups is shown below:
 
 {{clade example|code=|output=
 |code1=&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;{{clade
 |label1=root
 |1={{clade
    |1=Leaf 1 |bar1=green
    |2={{clade
       |1=Leaf 2&amp;nbsp; |bar1=green
       |bar2=red
       |2={{clade
          |1=Leaf 3&amp;nbsp; 
          |2=Leaf 4 
          }}
       }}
    }}
 |grouplabel1={{clade labels |width=10em;
              |label1=stem group  |top1=20% |color1=green
              |label2=crown group |top2=70% |color2=red
              }}  
 }}
 &lt;/syntaxhighlight&gt;
 |output1={{clade
 |label1=root
 |1={{clade
    |1=Leaf 1 |bar1=green
    |2={{clade
       |1=Leaf 2&amp;nbsp; |bar1=green
       |bar2=red
       |2={{clade
          |1=Leaf 3&amp;nbsp; 
          |2=Leaf 4 
          }}
       }}
    }}
 |grouplabel1={{clade labels |width=10em;
              |label1=stem group  |top1=20% |color1=green
              |label2=crown group |top2=70% |color2=red
              }}  
 }}
 }}
 
 The {{para|grouplabel}} parameter can contain any Wikitext or allowed HTML content and this offers a lot of flexibility in customising cladograms. The following example uses {{para|grouplabel}} to add an alternative topology using {{tl|cladeR}}:
 
 {{clade example |code=|output=
 |code1=&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;{{clade
 |label1=''Panthera''
 |1={{clade
    |1={{clade
       |1=snow leopard
       |2=tiger
       }}
    |2={{clade
       |1=jaguar
       |2={{clade
          |1=lion
          |2=leopard
          }}
       }}
    }}
 |grouplabel1=&lt;nowiki/&gt;{{cladeR
       |label1=&amp;nbsp;
       |1={{cladeR
          |1={{cladeR
             |1={{cladeR |1=&amp;nbsp;}}
             |2={{cladeR |1=&amp;nbsp;}}
             }}
          |label2=&amp;nbsp;
          |2={{cladeR
             |1={{cladeR
                |1=&amp;nbsp;
                |2=&amp;nbsp;
                }}
             |2={{cladeR |1=&amp;nbsp;}}
             }}
          }}   
       }}
 
 }}
 }}&lt;/syntaxhighlight&gt;
 |output1={{clade
 |label1=''Panthera''
 |1={{clade
    |1={{clade
       |1=snow leopard
       |2=tiger
       }}
    |2={{clade
       |1=jaguar
       |2={{clade
          |1=lion
          |2=leopard
          }}
       }}
    }}
 |grouplabel1=&lt;nowiki/&gt;{{cladeR
       |label1=&amp;nbsp;
       |1={{cladeR
          |1={{cladeR
             |1={{cladeR |1=&amp;nbsp;}}
             |2={{cladeR |1=&amp;nbsp;}}
             }}
          |label2=&amp;nbsp;
          |2={{cladeR
             |1={{cladeR
                |1=&amp;nbsp;
                |2=&amp;nbsp;
                }}
             |2={{cladeR |1=&amp;nbsp;}}
             }}
          }}   
       }}
 }}
 }}
 
 ===Debugging===
 
 If your cladogram doesn't display brackets/bars as you expected, check that:
 * You understand the numbering system for the parameters &lt;code&gt;barN&lt;/code&gt;, etc. The N must be the same as the number of the child within its clade. Thus typically you should write &lt;code&gt;{{!}}N=''label for leaf''{{!}}barN=''colour for bar''&lt;/code&gt;, e.g. &lt;code&gt;{{!}}2=&lt;nowiki&gt;[[Passeridae]]&lt;/nowiki&gt;{{!}}bar2=midnightblue&lt;/code&gt;.
 * You have only attempted to apply brackets/bars to ''leaf'' nodes.
 
 ==Limitations==
 
 ===Label length===
 Labels produced by &lt;code&gt;|labelN=&lt;/code&gt;, where &lt;code&gt;N&lt;/code&gt; 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 &lt;code&gt;|N=&lt;/code&gt;.) 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;amp;nbsp; not as actual spaces.
 * Line breaks (i.e. &lt;nowiki&gt;&lt;br/&gt;&lt;/nowiki&gt;) should not be used.
 
 ===Browser differences===
 
 [[File:Cladograms - browser variation.png|thumb|Browser variation: left – most browsers; right – Safari
 ]]
 
 Cladograms are drawn by generating 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, {{as of|2017|January|lc=yes}}, there are two algorithms for laying out tables with empty cells, used by two groups of browsers. Most browsers now use the algorithm that produces cladograms like the two on the left in the diagram. Safari (under both MacOS and iOS) uses another algorithm, producing cladograms like the two on the right in the diagram.
 
 No automated &quot;fix&quot; for these differences exists at present.
 
 If there is a choice over the ordering of the terminal nodes (leaves) of the tree, cladograms look best in a Safari-like browser if as much branching as possible is at the bottom of the cladogram. Typically this is produced by arranging the terminal nodes ''downwards'' on the page in order of their evolutionary divergence. Compare the bottom row of the diagram to the top row.
 
 ===Inclusion in books===
 There are many known bugs in rendering tables in the software which produces [[Help:Books|Wikipedia books]]; see the [https://meta.wikimedia.org/wiki/Book_tool/Feedback book tool feedback page].
 {{as of|2011|July|}} these result in the lines in cladograms not displaying in books. (Cladograms are implemented as HTML tables, which allows complex but hard-to-convert formatting. For an alternative
 way to include book cladograms, try images.)
 
 ===Large cladograms===
 There are limitations on the size and complexity of the cladograms which can be drawn:
 * A maximum of 20 children is allowed per node. &lt;!-- this is arbitrary and can be increased if required)--&gt;
 {{clade gallery |vertical= |align=right |width=300px
 |footer1=Example exceeding the expansion depth on the twentieth nested clade template.
 |cladogram1={{clade |style=line-height:65%;font-size:65%;
 |1=1|2={{clade
 |1=2|2={{clade
 |1=3|2={{clade
 |1=4|2={{clade
 |1=5|2={{clade
 |1=6|2={{clade
 |1=7|2={{clade
 |1=8|2={{clade
 |1=9|2={{clade
 |1=10|2={{clade
 |1=11|2={{clade
 |1=12|2={{clade
 |1=13|2={{clade
 |1=14|2={{clade
 |1=15|2={{clade
 |1=16|2={{clade
 |1=17|2={{clade
 |1=18|2={{clade
 |1=19|2={{clade
 |1=20|2={{clade
 }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
 }}
 * The Wikimedia software has certain limits on the processing allowed by templates and modules. Large cladograms can potentially exceed some of these limits.
 ** Post-expand include size. Essentially this is the output of all templates, modules and parser calls. Pages with very large or several large cladograms will occasionally exceed this limit, especially on larger pages with many references and other demands on the system.
 ** Template expansion depth limit. When a template is used it adds to the expansion depth, once for the template expansion and once for parameter expansion. As a result, template calls can only be nested 20 deep. Because cladograms are built by nesting templates within each other this is a common problem on larger phylogenetic trees. Fortunately there are now ways around this problem (see following section ).
 
 ==Techniques for building large cladograms.==
 
 Because cladograms are build by nesting {{tl|clade}} templates within each other, larger cladograms can exceed the expansion depth allowed by the Wikimedia software. The cladogram on the right fails on the twentieth nested clade template.
 
 There are two methods to get around this limitation: 
 * the use of the {{tl|clade sequential}} template and 
 * the use of subtrees within the {{tl|clade}} template. 
 
 ===Using sequential listing of taxa===
 
 This approach uses the template {{tl|clade sequential}} to list taxa in a [[taxonomic sequence]]. In the following example six taxa are listed sequentially in the template and the cladogram has the first one as the first branch, the second next and so on until the final two are sisters. Because all taxa are added in one template call, this only counts once towards the 20 limit. The downside is that it is not possible to format each level independently.
 
 {{clade example |code=|output=
 |code1=&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;{{clade sequential
         |1=Leaf 1
         |2=Leaf 2
         |3=Leaf 3
         |4=Leaf 4
         |5=Leaf 5
         |6=Leaf 6
         }}&lt;/syntaxhighlight&gt;
 |output1={{clade sequential
         |1=Leaf 1
         |2=Leaf 2
         |3=Leaf 3
         |4=Leaf 4
         |5=Leaf 5
         |6=Leaf 6
         }}
 |code2=&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;{{clade sequential
         |1=Leaf 1
         |label2=Clade 2
         |2={{clade 
            |1=Leaf 2A 
            |2=Leaf 2B
            }}
         |3=Leaf 3
         |label4=Clade 4
         |4={{clade 
            |1=Leaf 4A 
            |2=Leaf 4B
            }}
         |5=Leaf 5
         |6=Leaf6
         }}&lt;/syntaxhighlight&gt;
 |output2={{clade sequential
         |1=Leaf 1
         |label2=Clade 2
         |2={{clade 
            |1=Leaf 2A 
            |2=Leaf 2B
            }}
         |3=Leaf 3
         |label4=Clade 4
         |4={{clade 
            |1=Leaf 4A 
            |2=Leaf 4B
            }}
         |5=Leaf 5
         |6=Leaf6
         }}
 }}
 
 The second example shows that some substructure can be added to each level with normal use of the {{t|clade}} template.
 
 
 === Using subtrees ===
 
 This method uses the parameters {{para|target}} and {{para|subclade}} to &quot;modularise&quot; the phylogenetic tree. Each subtree is processed in parallel so they don't contribute to the expansion depth in an additive manner. The limit applies to each tree, but many subtrees can be used. 
 
 The basic arrangement is illustrated below. The main tree has two subclades, A and B, and subclade B calls a third.
 
 {{clade example |decription=|code=|output=
 
 |description1x=Basic tree without subclades
 |code1=&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;{{Clade
 |label1=root |sublabel1=[12/40]
 |1={{Clade
    |1=Leaf 1
    |2={{clade
       |1=Leaf 2.1
       |2={{clade
          |1=Leaf 2.2.1
          |2={{clade
             |label1=Subclade A
             |1={SUBCLADE_A}  
             |label2=Subclade B
             |2={SUBCLADE_B}  
             }}
          }}
       }}
    }}
 |targetA ={SUBCLADE_A}
 |subcladeA={{Clade
            |1=Leaf A1
            |2={{clade
               |1=Leaf A2.1
               |2={{clade
                  |1=Leaf A2.2.1
                  |2=Leaf A2.2.2
                  }}
               }}
            }}
 |targetB = {SUBCLADE_B}
 |subcladeB={{Clade
            |1=Leaf B1
            |2={{clade
               |1=Leaf B.1
               |2={{clade
                  |1=Leaf B2.2.1
                  |label2=Subclade C
                  |2={TARGET_C}
                  }}
               }}
            }}
 |targetC = {TARGET_C}
 |subcladeC={{Clade
            |1=Leaf C1
            |2={{clade
               |1=Leaf C2.1
               |2={{clade
                  |1=Leaf C2.2.1
                  |2=Leaf C2.2.2
                  }}
               }}
            }}          &lt;/syntaxhighlight&gt;
 |output1={{Clade
 |label1=root |sublabel1=[12/40]
 |1={{Clade
    |1=Leaf 1
    |2={{clade
       |1=Leaf 2.1
       |2={{clade
          |1=Leaf 2.2.1
          |2={{clade
             |label1=SubcladeA
             |1={SUBCLADE_A}  
             |label2=SubcladeB
             |2={SUBCLADE_B} 
             }}
          }}
       }}
    }}
 |targetA ={SUBCLADE_A}
 |subcladeA={{Clade
            |1=Leaf A1
            |2={{clade
               |1=Leaf A2.1
               |2={{clade
                  |1=Leaf A2.2.1
                  |2=Leaf A2.2.2
                  }}
               }}
            }}
 |targetB = {SUBCLADE_B}
 |subcladeB={{Clade
            |1=Leaf B1
            |2={{clade
               |1=Leaf B.1
               |2={{clade
                  |1=Leaf B2.2.1
                  |label2=SubcladeC
                  |2={TARGET_C}
                  }}
               }}
            }}
 |targetC = {TARGET_C}
 |subcladeC={{Clade
            |1=Leaf C1
            |2={{clade
               |1=Leaf C2.1
               |2={{clade
                  |1=Leaf C2.2.1
                  |2=Leaf C2.2.2
                  }}
               }}
            }}          
 }}
 }}
 
 The encoding relies on a number of conventions.
 
 * The names of the subclades are in uppercase and enclosed in a single brace. This is not absolutely necessary, as long as the names are unique, but some advanced features (e.g. partial tranclusion) rely on this convention.
 * The parameters {{para|subcladeA}}, {{para|subcladeB}}, ... {{para|subcladeZ}} contain the subtrees in clade structure that will be substituted into the main tree.
 * The parameters {{para|targetA}}, {{para|targetB}}, ... {{para|subcladeZ}} contain the targets where the subtrees will be substituted. For instance, {{para|targetA|{SUBCLADE_A}}} indicates that the target &lt;code&gt;{SUBCLADE_A}&lt;/code&gt; will be replaced by the content of {{para|subcladeA|''content''}}.
 * The target parameters may be omitted and the default targets are &lt;code&gt;{SUBCLADE_A}&lt;/code&gt; and &lt;code&gt;{SUBCLADE_B}&lt;/code&gt; for {{para|subcladeA}} and {{para|subcladeB}}, respectively.
 * The suffixes A-Z were chosen because these parameters don't correspond the other numbered parameters used by the template (e.g. {{para|1}}, {{para|label2}} etc.
 * The subclades can all be listed in the outer clade template or nested within the appropriate tree. For instance, in the example subclade C is listed at the end of the outer clade template but this could have been nested in the clade template attached to subtree B.
 
 An example of a large phylogenetic tree divided into multiple subtrees can be found at {{tl|Phylogeny/APG IV}}.
 
 ===Add interactivity with collapsible clades===
 {{further|Template:Clade hidden}}
 Sometimes with large phylogenetic trees it is hard to see the wood for the trees. The cladogram may exceed the screen height making it difficult to see the overall structure and important small clades are too hard to see. A way around this is to collapse the large clades and expand them interactively.
 
 The following example shows a simple example to illustrate the principle:
 
 {{clade example |code=|output=
 |code1=&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;{{clade |style=font-size:80%;line-height:90%;
 |label1='''Amphibia'''
 |1={{clade
    |1=[[Gymnophiona]] (caecilians)
    |label2=[[Batrachia]]
    |2={{clade hidden |id=1 |mode=left
       |expand-text=(frogs and salamanders)          
       |1=[[Caudata]] (salamanders)
       |2=[[Anura (frog)|Anura]] (frogs)
       }}
    }}
 }}&lt;/syntaxhighlight&gt;
 |output1={{clade |style=font-size:80%;line-height:90%;
 |label1='''Amphibia'''
 |1={{clade
    |1=[[Gymnophiona]] (caecilians)
    |label2=[[Batrachia]]
    |2={{clade hidden |id=1 |mode=left
       |expand-text=(frogs and salamanders)          
       |1=[[Caudata]] (salamanders)
       |2=[[Anura (frog)|Anura]] (frogs)
       }}
    }}
 }}
 }}
 
 A note of caution. The Wikimedia collapsible elements require javascript and are currently disabled in the mobile view. In such cases the whole cladogram will be shown. As with any large phylogentic trees, editors should decide if having a smaller less inclusive tree makes the point more clearly. 
 
 {{clear}}
 
 == Graphical summary ==
 
 {{Clade/doc/graphic summary}}