%example file for demonstrating the usage of xq.sty. 
\documentclass[twocolumn,11pt]{article}
\usepackage{xq}

\parindent 0pt
\setlength{\columnsep}{5mm}
\setlength{\textheight}{220mm}
\setlength{\headheight}{13.6pt}
\setlength{\hoffset}{-3.0mm}
\setlength{\voffset}{-6.0mm}

\begin{document}

\texttt{The xq package is made for writing about Xiangqi or Chinese chess. This file demonstrates what the package can do.}

\mylanguage english
%i ve tried to enable input of the language typical letters for the different pieces. By now there 
%are letters defined for: 
%
%"german" (King=F, Advisor/Guard=M, Elephant=E, Chariot=W, Cannon=K, Horse=P, Soldier=S - for red pieces
% and corresponding lower cases for black pieces) 
%"english" (K,A,E,R,C,H,P); 
%"spanish" (R,O,E,T,B,C,P); 
%"italian" (R,M,E,T,B,C,P); 
%"french" (R,M,E,T,B,C,P);  
%"czech" (K,R,S,V,D,J,P) and 
%"dutch" (G,A,O,T,K,P,S)
%
%If you want to add your language or do not like the letters I used goto xq.sty and use the pattern 
%to define the letter definitions according to your preferences. Please rename the style file, if you 
%make any changes. 
%This selection affects on the one hand the letters for the pieces when setting up a position in the 
%input file and on the other hand the letters for pieces shown in the move blocks in the output file. 

\bigskip
\texttt{First we write down a complete game.}
\newgame
%defines the board with the start position, the movecount, shown in the move blocks, is set to 0.

\begin{center}
{\bf\large{Player\,1\,--\,Player\,2}}
\end{center}

\move f1e2 h8e8 
%note that there is absolutely no check for legal moves - this means, that on the one hand any piece can move to any place, even to the place it comes from and on the other hand a piece moved from/to a place that does not exist on the board will not be shown, selecting an empty square as start square produces an error - so everything has to be correct here
\bigskip
\texttt{Moves are input like this: "\textbackslash{}move f1e2 h8e8". The letter of the piece moved is generated automatically and also, whether it is a capture or not. The piece letters shown depend on the language, you choose at the beginning of the .tex file, in this case it is "english". By now there are letters defined for English, Spanish, French, Italian, Czech, Dutch and my mother tongue: German. I created a pattern in the style file, where you can add your language typical letters, if the ones already defined do not match your preferences.} \\
\bigskip

\move h1g3 h0g8
\move b1c3 i0h0
\move i1h1 h0h6
\move h3h5 b0a8
\move c4c5 b8c8
\move c1e3 c7c6
\move c3b5 c6c5
\move e3c5 h6c6
\move c5e3 g7g6
\move b5a7 c6c3
\move b3b6 c3c7
\move h5h7 e7e6
\cr ! 
%shows the comment you input here after the next red move 
\move b6g6 xxxx 
%shows a move only of red, actually, only the first letter of the side, that does not move, has to be a "x", but it have to be 4 letters

\newpage

\showboard 
%shows the board in a size fitted to twocolumn on a4paper according to my personal preference, the position shown should be the one the moves input are leading to
\texttt{The board is shown with a single command. The style finds the correct position depending on the moves you input.}
\bigskip
\cb ? 
%the same for next black move
\move xxxx c7a7 
%move only of black
Black wins a major piece, but more important is that Red gets a strong attack on the right wing of the board.
\cr + 
\move g6g0 f0e9
\cr +
\move h7h0 xxxx 

It is not better for Red to play \bv 16.Ci0, for after 16|Kf0 17.Chh0+ Kf9 18.Rh9+ Kf8 19.Rg9 Hh6 20.Rg6 \ev Red gets back the major  piece only\dots %between \bv and \ev  "|" produces \ldots, "*" produces \times (the capturing symbol), if you need these to be output, use \makevisible*\makeactive

\move xxxx g8h0
\move h1h0 a0a9
\cr +
\move g0d0 e9f0
\move d0f0 a9f9
\cr +
\move f0c0 xxxx 
but in the game Red takes the whole defense of Black\dots 
\move xxxx e0e9
\move a1b1 a7f7
\cr + 
\move b1b9 c8c9
\move c0a0 e8d8

\newpage

\showwesternboard

\texttt{You can also show the board with western pieces using \textbackslash{}showwesternboard.}
\bigskip

\move b9a9 d8d2
\move a0a8 xxxx
\dots and the major piece.
\move xxxx e9e8
\cr +
\move h0h8 f7f8
\move a9c9 xxxx
Black resigned the game.
\begin{center}
{\bf{\large{1\,:\,0}}}
\end{center}

\newpage
\newpage

\texttt{Now we start playing from a special position, that is input in the .tex file.}

\begin{center}
{\bf{\large{Exercise}}}
\end{center}
In the diagram shown below, both sides can checkmate the opponent, depending only on who is to move.

\resetboard 
%makes the board to show an empty one, recommended before setting up a position

\piece Ec1
%by now positions have to be input piece by piece which is not so cool, sorry :-) 
\piece Ke1
\piece Af1
\piece Rh1
\piece Ae2
\piece Ha3
\piece Ee3
\piece Pc4
\piece Pg4
\piece Pi4
\piece Pa5
\piece ce5
\piece Ci5
\piece pc6
\piece rd6
\piece pg6
\piece pa7
\piece pe7
\piece Cg7
\piece hc8
\piece ee8
\piece hg8
\piece ae9
\piece ec0
\piece ke0
\piece af0

\showboard

1.\,Red to move, checkmates in 3 moves\\
2.\,Black to move, checkmates in 4 moves\\

\textit{Solution}\\

1.\,Red to move
\movecount=0
\cr +
\move i5i0 g8h0
\cr +
\move g7g0 e8g0
\cr \#
\move i0g0 xxxx

\resetboard

\piece Ec1
\piece Ke1
\piece Af1
\piece Rh1
\piece Ae2
\piece Ha3
\piece Ee3
\piece Pc4
\piece Pg4
\piece Pi4
\piece Pa5
\piece ce5
\piece Ci5
\piece pc6
\piece rd6
\piece pg6
\piece pa7
\piece pe7
\piece Cg7
\piece hc8
\piece ee8
\piece hg8
\piece ae9
\piece ec0
\piece ke0
\piece af0

\bigskip
2.\,Black to move

\movecount=1
\move xxxx e0d0
\cr +
\move i5i0 d0d9
\cr +
\move i0i9 d9d8
\move i9i6 xxxx
\dots or any other move
\cb \#
\move xxxx d6d1 

\newpage

\texttt{I added some additional signs to demonstrate legal moves of pieces.\\But for now this is not more than a first draft with only the four extra signs shown in the diagram.}

\resetboard

\piece Ke1
\addsign Ld1
\addsign Lf1
\addsign Le2

\piece ng8
\piece pg7
\addsign Uf6
\addsign Uh6
\addsign Li7
\addsign Li9
\addsign Lh0
\addsign Lf0
\addsign Le9
\addsign Le7

\addsign Ra1
\addsign Ba0

\showboard
%pieces in running text
\newpage

\texttt{Pieces in running text:}
\bigskip

\textpiece K \textpiece k 
the kings 

\vspace{2pt}

\textpiece A \textpiece a 
the advisors/guards

\makebox[21pt][c]{\vdots}

\vspace{4pt}
\westerntextpiece H \westerntextpiece h 
the knights/horses

\vspace{2pt}

\westerntextpiece P \westerntextpiece p 
the pawns/soldiers
\vspace{2pt}

%finally a large board
\newpage
\onecolumn

\newgame
\texttt{I also included commands to show large boards: \textbackslash{}showlargeboard and \textbackslash{}showlargewesternboard.}
\showlargeboard 
%shows a board in a size fitted to onecolumn on a4paper according to my personal preference. For western pieces input \showlargewesternboard

\texttt{That's all! Hopefully everything works like it should!}

\end{document}

%Stephan Weinhold 09.2006
%stewei@surfeu.de
