Template:Chess/theory table
This template create formatted theory wikitables from human-readable lines (as from a pgn). It also automatically links the first move of each variant line (can be disabled).
For a general introduction to theory tables, check out Chess/Opening theory table.
Usage
Chess/theory table automatically formats lines. Each line forms a new row in the table. Lines are entered with the lineN parameter, where N is an integer.
It can take any number of lines of any length, creating as many columns as it needs. The lines do not need to all be the same length.
Optionally, a name and/or an evaluation can be provided for each line with nameN and evalN respectively. These will go to their correct positions in the table irrespective of how long the line is.
{{Chess/theory table |preceding=1. e4 e5 2. Nf3 NC6 |name1=Italian game |line1=3. Bc4 Bc5 4. c3 Nf6 5. d3 d6 |eval1=+- |name2=Two knights defence |line2=3... Nf6 4. Ng5 d5 5. exd5 Na5 6. Bb5+ c6 7. dxc6 bxc6 8. Bd3 |eval2=∞ |line3=3... ... 4. ... ... 5. ... ... 6. ... ... 7. ... Nxc6 8. O-O |name4=Spanish game |line4=3. Bb5 a6 4. Ba4 Nf6 5. O-O |name5=Modern Steinitz |line5=3... ... 4. ... d6 5. O-O }}
1. e4 e5 2. Nf3 NC6
3 | 4 | 5 | 6 | 7 | 8 | ||
---|---|---|---|---|---|---|---|
Italian game | Bc4 Bc5 | c3 Nf6 | d3 d6 | +- | |||
Two knights defence | ... Nf6 | Ng5 d5 | exd5 Na5 | Bb5+ c6 | dxc6 bxc6 | Bd3 | ∞ |
... ... | ... ... | ... ... | ... ... | ... Nxc6 | O-O | ||
Spanish game | Bb5 a6 | Ba4 Nf6 | O-O | ||||
Modern Steinitz | ... a6 | Ba4 d6 | O-O |
Line order and diverging lines
As in all theory tables, the lines must be organised in a tree-like hierarchy, mainly first with variations underneath. Moves that are the same as the line above are represented with three dots ... which is the theory table equivalent of a ditto.
e4 e5 Nf3 Nc6 Bc4 Nf6 - line 1 (parent/mainline) ... ... ... ... Bb5 a3 - line 2 (child line) ... ... ... ... ... Nf6 - line 3 (grandchild line) ... ... ... Nf6 - line 4 (new child line) d4 d5 c4 - line 5 (new parent/mainline)
The implications this has for layout is 1. all lines must diverge from some line above them not after them, 2. all lines must diverge from the first one above them that has fewer dotted moves (dittos) than it does.
As well just being how theory tables are organised, this format allows the code to correctly determine which lines diverge from which, which is used in generating wikilinks.
Preceding moves
The moves preceding those line in the table are printed above the table. It will automatically read the moves from the page title (which will work if the page title is of the format Chess Opening Theory/1. e4/1...e5/2. Nf3/2...Nc6), or this can be overridden and passed to the template directly in the preceding parameter. The preceding moves are used to determine at what number to start the table: the move numbers provided in the line are to make it human readable and adjustable but are not used in the template directly.
Wikilinks
The first original move in each line is automatically wikilinked to the page for that move. This takes into account the moves from parent line(s) and the preceding moves. This behaviour can be suppressed by setting the links parameter to false or 0 (default true).