Template:Chess diagram small

From Wikibooks, open books for an open world
Jump to: navigation, search
{{{2}}}
Solid white.svg a b c d e f g h Solid white.svg
8 a8 black king b8 black king c8 black king d8 black king e8 black king f8 black king g8 black king h8 black king 8
7 a7 black king b7 black king c7 black king d7 black king e7 black king f7 black king g7 black king h7 black king 7
6 a6 black king b6 black king c6 black king d6 black king e6 black king f6 black king g6 black king h6 black king 6
5 a5 black king b5 black king c5 black king d5 black king e5 black king f5 black king g5 black king h5 black king 5
4 a4 black king b4 black king c4 black king d4 black king e4 black king f4 black king g4 black king h4 black king 4
3 a3 black king b3 black king c3 black king d3 black king e3 black king f3 black king g3 black king h3 black king 3
2 a2 black king b2 black king c2 black king d2 black king e2 black king f2 black king g2 black king h2 black king 2
1 a1 black king b1 black king c1 black king d1 black king e1 black king f1 black king g1 black king h1 black king 1
Solid white.svg a b c d e f g h Solid white.svg
[edit] [history] [purge] Template documentation

Syntax[edit]

There are two standard chess diagram templates:

The syntax is basically the same for both of them.

{{chess diagram
| <alignment> (param #1)
| <header>    (#2) 
| size =
| numbers =
| letters =
| <a8> | <b8> | ... | <h8>  (#3 to ...
| <a7> | <b7> | ... | <h7>
...
| <a1> | <b1> | ... | <h1>  ( ... #66)
| <footer> (#67)
}}

Parameters:

  • <alignment> – defines horizontal alignment (floating) of the whole table, must be tright or tleft (or nothing)
  • <header> – the text which appears above the diagram, may be empty;
  • size - specifies the size of each square in pixels, the default is 26.
  • numbers - specifies whether the rows are numbered. Options are: left, right, both (default) or neither.
  • letters - specifies whether the columns are lettered. Options are: top, bottom, both (default) or neither.
  • <a8>, <b8>, ... <h1> – define corresponding squares of the chessboard, see below;
  • <footer> – the text which appears beneath the diagram, may be empty; optional – can be left out (currently not in the other templates)

A square is defined by the name of piece or empty parameter. The names of the pieces are those given in algebraic notation:

  • Chess kll45.svg Chess kld45.svg Chess kdl45.svg Chess kdd45.svg k = king
  • Chess qld45.svg Chess qll45.svg Chess qdd45.svg Chess qdl45.svg q = queen
  • Chess rll45.svg Chess rld45.svg Chess rdl45.svg Chess rdd45.svg r = rook
  • Chess bld45.svg Chess bll45.svg Chess bdd45.svg Chess bdl45.svg b = bishop
  • Chess nll45.svg Chess nld45.svg Chess ndl45.svg Chess ndd45.svg n = knight
  • Chess pld45.svg Chess pll45.svg Chess pdd45.svg Chess pdl45.svg p = pawn

There are also some fairy chess pieces available:

  • Chess all44.png Chess ald44.png Chess adl44.png Chess add44.png a = archbishop (knight + bishop compound)
  • Chess cld44.png Chess cll44.png Chess cdd44.png Chess cdl44.png c = chancelor (knight + rook compound)
  • Chess fll45.svg Chess fld45.svg Chess fdl45.svg Chess fdd45.svg f = upside-down king
  • Chess gld45.svg Chess gll45.svg Chess gdd45.svg Chess gdl45.svg g = upside-down queen
  • Chess mll45.svg Chess mld45.svg Chess mdl45.svg Chess mdd45.svg m = upside-down rook
  • Chess eld45.svg Chess ell45.svg Chess edd45.svg Chess edl45.svg e = upside-down bishop
  • Chess sll45.svg Chess sld45.svg Chess sdl45.svg Chess sdd45.svg s = upside-down knight
  • Chess hld45.svg Chess hll45.svg Chess hdd45.svg Chess hdl45.svg h = upside-down pawn
  • Chess zll44.png Chess zld44.png Chess zdl44.png Chess zdd44.png z = champion (for Omega Chess)
  • Chess wld44.png Chess wll44.png Chess wdd44.png Chess wdl44.png w = wizard (for Omega Chess)

These letters are combined with either "l" for Light=White, or "d" for Dark=Black. So "kl" is White's king, and "nd" is Black's knight.

An empty square is written either using underscores, spaces, or nothing at all. Two spaces are recommended.

  • Chess d45.svgChess l45.svg <space> = empty square

You can also use "xx" for a cross, "xo" for a black circle on an empty square or "oo" for a white one.

  • Chess xxd45.svgChess xxl45.svg xx = cross/x
  • Chess xod45.svgChess xol45.svg xo = black circle
  • Chess ood45.svgChess ool45.svg oo = white circle

Numbers can also be added to squares by using "x0" for 0, "x1" for 1, "x2" for 2, ..., "x9" for 9.

  • Chess x0d45.svgChess x0l45.svg x0
  • Chess x1d45.svgChess x1l45.svg x1
  • Chess x2d45.svgChess x2l45.svg x2
  • Chess x3d45.svgChess x3l45.svg x3
  • Chess x4d45.svgChess x4l45.svg x4
  • Chess x5d45.svgChess x5l45.svg x5
  • Chess x6d45.svgChess x6l45.svg x6
  • Chess x7d45.svgChess x7l45.svg x7
  • Chess x8d45.svgChess x8l45.svg x8
  • Chess x9d45.svgChess x9l45.svg x9

Examples[edit]

In the following examples the rows and columns are numbered. Because any text between "|=" and the next "|" is ignored, numbers and letters can be added without affecting output.

Standard diagram[edit]

This diagram is recommended for common use as a main diagram in books on chess openings, endings, games, positions etc. See the corresponding code below.

a b c d e f g h
8 {{{square}}} black rook {{{square}}} black knight {{{square}}} black bishop {{{square}}} black queen {{{square}}} black king {{{square}}} black bishop {{{square}}} black knight {{{square}}} black rook 8
7 {{{square}}} black pawn {{{square}}} black pawn {{{square}}} black pawn {{{square}}} black pawn {{{square}}} black king {{{square}}} black pawn {{{square}}} black pawn {{{square}}} black pawn 7
6 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king 6
5 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black pawn {{{square}}} black king {{{square}}} black king {{{square}}} black king 5
4 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} white pawn {{{square}}} white pawn {{{square}}} black king {{{square}}} black king 4
3 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king 3
2 {{{square}}} white pawn {{{square}}} white pawn {{{square}}} white pawn {{{square}}} white pawn {{{square}}} black king {{{square}}} black king {{{square}}} white pawn {{{square}}} white pawn 2
1 {{{square}}} white rook {{{square}}} white knight {{{square}}} white bishop {{{square}}} white queen {{{square}}} white king {{{square}}} white bishop {{{square}}} white knight {{{square}}} white rook 1
a b c d e f g h
The King's Gambit
{{chess diagram
| tright
| 
|= 

 8 |rd|nd|bd|qd|kd|bd|nd|rd|=
 7 |pd|pd|pd|pd|  |pd|pd|pd|=
 6 |  |  |  |  |  |  |  |  |=
 5 |  |  |  |  |pd|  |  |  |=
 4 |  |  |  |  |pl|pl|  |  |=
 3 |  |  |  |  |  |  |  |  |=
 2 |pl|pl|pl|pl|  |  |pl|pl|=
 1 |rl|nl|bl|ql|kl|bl|nl|rl|=
    a  b  c  d  e  f  g  h  

| The King's Gambit
}}

Diagram with both captions[edit]

W. Langstaff, Chess Amateur 1922
a b c d e f g h
8 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black rook 8
7 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king 7
6 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} white bishop {{{square}}} black king {{{square}}} white pawn 6
5 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} white rook {{{square}}} black king {{{square}}} white king {{{square}}} black pawn {{{square}}} white pawn 5
4 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king 4
3 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king 3
2 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king 2
1 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king 1
a b c d e f g h
Mate in two.
This problem uses partial retrograde analysis method.

It may be convenient to use this in the articles on chess problems. Please note that in the header and footer you can use bolds or italics. You can also use <br> to break the lines.

{{chess diagram
| tright
| '''W. Langstaff''', ''Chess Amateur'' 1922
|= 

 8 |  |  |  |  |kd|  |  |rd|=
 7 |  |  |  |  |  |  |  |  |=
 6 |  |  |  |  |  |bl|  |pl|=
 5 |  |  |  |rl|  |kl|pd|pl|=
 4 |  |  |  |  |  |  |  |  |=
 3 |  |  |  |  |  |  |  |  |=
 2 |  |  |  |  |  |  |  |  |=
 1 |  |  |  |  |  |  |  |  |=
    a  b  c  d  e  f  g  h  

| '''Mate in two.''' <br> This problem uses ''partial retrograde analysis'' method.
}}

Diagram without captions[edit]

a b c d e f g h
8 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king 8
7 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king 7
6 {{{square}}} black king {{{square}}} cross {{{square}}} black circle {{{square}}} cross {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king 6
5 {{{square}}} black king {{{square}}} black king {{{square}}} white pawn {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king 5
4 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black circle {{{square}}} black king {{{square}}} black king 4
3 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} cross {{{square}}} black circle {{{square}}} cross {{{square}}} black king 3
2 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} white pawn {{{square}}} black king {{{square}}} black king 2
1 {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king {{{square}}} black king 1
a b c d e f g h

See the corresponding code below. If you don't want the captions, just remove them, but don't delete the second "|" pipe character for the caption above; it is possible to delete the last pipe for the longer caption below.

The diagram floats to the left to illustrate the use of the first parameter.

{{chess diagram
| tleft
| 
|= 

 8 |  |  |  |  |  |  |  |  |=
 7 |  |  |  |  |  |  |  |  |=
 6 |  |xx|xo|xx|  |  |  |  |=
 5 |  |  |pl|  |  |  |  |  |=
 4 |  |  |  |  |  |xo|  |  |=
 3 |  |  |  |  |xx|xo|xx|  |=
 2 |  |  |  |  |  |pl|  |  |=
 1 |  |  |  |  |  |  |  |  |=
    a  b  c  d  e  f  g  h  
}}

Small diagram[edit]

This one may be useful in pages with many diagrams. It uses another template named {{chess diagram small}}.

The small diagrams can have header, too.

Solid white.svg a b c d e f g h Solid white.svg
8 a8 black rook b8 black king c8 black king d8 black queen e8 black king f8 black rook g8 black king h8 black king 8
7 a7 black pawn b7 black pawn c7 black king d7 black king e7 black pawn f7 black pawn g7 black bishop h7 black pawn 7
6 a6 black king b6 black knight c6 black pawn d6 black king e6 black king f6 black knight g6 black pawn h6 black king 6
5 a5 black king b5 black king c5 white queen d5 black king e5 black king f5 black king g5 white bishop h5 black king 5
4 a4 black king b4 black king c4 black king d4 white pawn e4 white pawn f4 black king g4 black bishop h4 black king 4
3 a3 black king b3 black king c3 white knight d3 black king e3 black king f3 white knight g3 black king h3 black king 3
2 a2 white pawn b2 white pawn c2 black king d2 black king e2 black king f2 white pawn g2 white pawn h2 white pawn 2
1 a1 black king b1 black king c1 black king d1 white rook e1 white king f1 white bishop g1 black king h1 white rook 1
Solid white.svg a b c d e f g h Solid white.svg
The position after 11. Bg5.
{{chess diagram small
| tright
| 
|= 

 8 |rd|  |  |qd|  |rd|kd|  |=
 7 |pd|pd|  |  |pd|pd|bd|pd|=
 6 |  |nd|pd|  |  |nd|pd|  |=
 5 |  |  |ql|  |  |  |bl|  |=
 4 |  |  |  |pl|pl|  |bd|  |=
 3 |  |  |nl|  |  |nl|  |  |=
 2 |pl|pl|  |  |  |pl|pl|pl|=
 1 |  |  |  |rl|kl|bl|  |rl|=
    a  b  c  d  e  f  g  h  

| The position after 11. Bg5.
}}