diff options
author | Karl Berry <karl@freefriends.org> | 2006-01-09 00:49:07 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-01-09 00:49:07 +0000 |
commit | 007f67a693e4d031fd3d792df8e4d5f43e2cb2e7 (patch) | |
tree | 90d17e00e572ecb1e24764b6f29c80e098b08d29 /Master/texmf-dist/doc/latex/skak | |
parent | 950209b26f70aa87ed07c54f82a95b6f03b7c3a0 (diff) |
doc/latex
git-svn-id: svn://tug.org/texlive/trunk@84 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/skak')
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/WC-2004-S-00007.tex | 98 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/andreas_wilm_1.tex | 28 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/angletst.tex | 52 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/demo-symbols.tex | 43 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/font.tex | 32 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/games.tex | 72 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/hightest.tex | 309 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/informator.tex | 83 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/ingo-bug1.tex | 21 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/lambda.tex | 1146 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/refman.tex | 309 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/skakdoc.tex | 417 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/syntax.tex | 321 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/test1.tex | 43 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/test2.tex | 41 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skak/tuggame.tex | 164 |
16 files changed, 3179 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/skak/WC-2004-S-00007.tex b/Master/texmf-dist/doc/latex/skak/WC-2004-S-00007.tex new file mode 100644 index 00000000000..dc1fdf597e8 --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/WC-2004-S-00007.tex @@ -0,0 +1,98 @@ +\documentclass[german,twocolumn,a4paper,twoside,10pt]{article} + +\usepackage{skak} +\usepackage{babel} +\newcommand{\chessgame}[4]{ + \begin{center} + \large{\textbf{#1} -- \textbf{#2}} + + \textsf{#3} + + \small{\textsc{#4}} + \end{center} +} + +\title{Semifinal IECG WC2004} +\author{Ingo Sander} +\begin{document} + +\maketitle + +\chessgame{Anatoly Sidenko}{Ingo Sander}{IECG:WC-2004-Semifinal, 2002}{} +\styleB +\newgame +\mainline{1. d4 d5 2. Nf3 Nf6 3.Bf4 c5 4.e3 Nc6 5.c3} +\[\showboard\] + +\chessgame{Ingo Sander}{Davor Matic}{IECG:WC-2004-Semifinal, 2002}{K\"{o}nigsindisch} +\styleB +\newgame +\mainline{1. Nf3 Nf6 2. c4 g6 3. Nc3 Bg7 4. e4 d6 5. d4 O-O 6. Be2 e5 7. O-O Nc6 8. d5 Ne7 9. b4 a5 10. Ba3 Nd7} +%11. bxa5 Rxa5 12. Bb4 Ra8 13. a4 Bh6 14. a5 f5 15. Nd2 Nf6 16.c5 Bxd2 17.Qxd2 fxe4} +\[\showboard\] + +\chessgame{Ingo Sander}{Davor Matic}{IECG:WC-2004-Semifinal, 2002}{K\"{o}nigsindisch} +\styleB +\newgame +\mainline{1. Nf3 Nf6 2. c4 g6 3. Nc3 Bg7 4. e4 d6 5. d4 O-O 6. Be2 e5 7. O-O Nc6 8. d5 Ne7 9. b4 a5 10. Ba3 Nd7 11. bxa5 Rxa5 12. Bb4 Ra8 13. a4 Bh6 14. a5 f5 15. Nd2 Nf6 16.c5 Bxd2 17.Qxd2 fxe4} +\[\showboard\] + + +\chessgame{James Miller}{Ingo Sander}{IECG:WC-2004-Semifinal, 2002}{Caro-Kann} +\styleB +\newgame +\mainline{1.e4 c6 2.d4 d5 3.Nc3 dxe4 4.Nxe4 Nd7 5.Ng5 Ngf6 6.Bd3 e6 7.N1f3 Bd6 8.Qe2 h6 9.Ne4} +\[\showboard\] + +\chessgame{Ingo Sander}{Juan A. Fabiani}{IECG:WC-2004-Semifinal, 2002}{} +\styleB +\newgame +\mainline{1.Nf3 Nf6 2.c4 e6 3.Nc3 d5 4.d4 c6 5.e3 Nbd7} +\[\showboard\] + +\chessgame{Harold Edighoffer}{Ingo Sander}{IECG:WC-2004-Semifinal, 2002}{} +\styleB +\newgame +\mainline{1.e4 c6 2.d4 d5 3.e5 Bf5 4.Bd3 Bxd3} +\[\showboard\] + +\chessgame{Ingo Sander}{Alain Lacoste}{IECG:WC-2004-Semifinal, 2002}{Englisch 1. $\dots$ c5} +\styleB +\newgame +\mainline{1.Nf3 c5 2.c4 Nf6 3.Nc3 Nc6 4.g3 d5 5.d4 cxd4 6.Nxd4 dxc4 7.Nxc6 Qxd1+ 8.Nxd1 bxc6 9.Bg2 Nd5 10.Ne3 e6 11.Nxc4 Ba6 12.Na5 Bb4+ 13.Bd2 Bxa5 14.Bxa5 Rb8 +15.b3 Ke7} +\[\showboard\] + +\chessgame{Holger Kiefhaber}{Ingo Sander}{IECG:WC-2004-Semifinal, 2002}{Caro-Kann} +\styleB +\newgame +\mainline{1.e4 c6 2.d4 d5 3.exd5 cxd5 4.c4 Nf6 5.Nc3 e6 6.Nf3 Bb4 7.cxd5 Nxd5 8.Bd2 Nc6 9.Bd3 O-O 10.O-O Be7} +\[\showboard\] + +\chessgame{Ingo Sander}{Manfred Fritz}{IECG:WC-2004-Semifinal, 2002}{} +\styleB +\newgame +\mainline{1.Nf3 Nf6 2.c4 b6 3.g3 c5 4.Bg2 Bb7 5.O-O} +\[\showboard\] + +\begin{table*}[htbp] + \centering + \begin{tabular}{|llr|ccccccccc|c|c|} +\hline +Sidenko, Anatoly & RUS & 2293 & - & & & & & & & & & 0,0 & 1 \\ +Matic, Davor & CRO & 2310 & & - & & & & & & & & 0,0 & 1 \\ +Miller, James & ENG & 2109 & & & - & & & & & & & 0,0 & 1 \\ +Fabiani, Juan A. & ESP & 2382 & & & & - & & & & & & 0,0 & 1 \\ +Edighoffer, Harold & USA & 2433 & & & & & - & & & & & 0,0 & 1 \\ +Sander, Ingo & GER & 2197 & & & & & & - & & & & 0,0 & 1 \\ +Lacoste, Alain & FRA & 2009 & & & & & & & - & & & 0,0 & 1 \\ +Kiefhaber, Holger & GER & 2250 & & & & & & & & - & & 0,0 & 1 \\ +Fritz, Manfred & GER & 2348 & & & & & & & & & - & 0,0 & 1 \\ +\hline + \end{tabular} + \caption{Semifinale IECG WC 2004 (Gruppe 7)} + \label{tab:ResultatWC2004} +\end{table*} + +\end{document} + diff --git a/Master/texmf-dist/doc/latex/skak/andreas_wilm_1.tex b/Master/texmf-dist/doc/latex/skak/andreas_wilm_1.tex new file mode 100644 index 00000000000..ccc49ffc866 --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/andreas_wilm_1.tex @@ -0,0 +1,28 @@ +\documentclass[twocolumn]{article} + +\usepackage{skak} + + +\begin{document} + +\styleC +\newgame + +\fenboard{r4q2/1b2nBrk/pp3p1p/4p3/4p3/2N1R2Q/PPP2PPP/R5K1 w - - 0 26} + +\[\showboard\] + +\mainline{26. Qxh6 Kxh6 27. Rh3+ Kg5} + + + +\[\showboard\] + + + +\end{document} + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: t +%%% End: diff --git a/Master/texmf-dist/doc/latex/skak/angletst.tex b/Master/texmf-dist/doc/latex/skak/angletst.tex new file mode 100644 index 00000000000..7198260c861 --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/angletst.tex @@ -0,0 +1,52 @@ +%% Name: angletst.tex +%% Author: Dirk Baechle +%% Date: 2003-01-23 + +\documentclass[12pt]{article} + +\usepackage[ps]{skak} + +\def\testfileangle#1#2#3{% + \texttt{#1 -> #2} + \printfileangle{#1}{#2} + should be: #3\newline} + +\def\testrankangle#1#2#3{% + \texttt{#1 -> #2} + \printrankangle{#1}{#2} + should be: #3\newline} + +\begin{document} + +\section{Test of the ``\texttt{fileangle}s''} + +\testfileangle{a}{b}{0} +\testfileangle{a}{c}{0} +\testfileangle{b}{a}{0}\testfileangle{b}{c}{0}\testfileangle{b}{d}{0} +\testfileangle{c}{a}{180}\testfileangle{c}{b}{0} +\testfileangle{c}{d}{0}\testfileangle{c}{e}{0} +\testfileangle{d}{b}{180}\testfileangle{d}{c}{0} +\testfileangle{d}{e}{0}\testfileangle{d}{f}{0} +\testfileangle{e}{c}{180}\testfileangle{e}{d}{0} +\testfileangle{e}{f}{0}\testfileangle{e}{g}{0} +\testfileangle{f}{d}{180}\testfileangle{f}{e}{0} +\testfileangle{f}{g}{0}\testfileangle{f}{h}{0} +\testfileangle{g}{e}{180}\testfileangle{g}{f}{0}\testfileangle{g}{h}{0} +\testfileangle{h}{f}{180}\testfileangle{h}{g}{0} + +\section{Test of the ``\texttt{rankangle}s''} + +\testrankangle{1}{2}{0}\testrankangle{1}{3}{90} +\testrankangle{2}{1}{0}\testrankangle{2}{3}{0}\testrankangle{2}{4}{90} +\testrankangle{3}{1}{270}\testrankangle{3}{2}{0} +\testrankangle{3}{4}{0}\testrankangle{3}{5}{90} +\testrankangle{4}{2}{270}\testrankangle{4}{3}{0} +\testrankangle{4}{5}{0}\testrankangle{4}{6}{90} +\testrankangle{5}{3}{270}\testrankangle{5}{4}{0} +\testrankangle{5}{6}{0}\testrankangle{5}{7}{90} +\testrankangle{6}{4}{270}\testrankangle{6}{5}{0} +\testrankangle{6}{7}{0}\testrankangle{6}{8}{90} +\testrankangle{7}{5}{270}\testrankangle{7}{6}{0}\testrankangle{7}{8}{0} +\testrankangle{8}{6}{270}\testrankangle{8}{7}{0} + +\end{document} diff --git a/Master/texmf-dist/doc/latex/skak/demo-symbols.tex b/Master/texmf-dist/doc/latex/skak/demo-symbols.tex new file mode 100644 index 00000000000..17dd65f6572 --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/demo-symbols.tex @@ -0,0 +1,43 @@ +\documentclass{article} +\usepackage{chess-workshop-symbols} +\begin{document} +\begin{tabular}{ll} +\verb|\wbetter| & \wbetter \\ +\verb|\bbetter| & \bbetter \\ +\verb|\wupperhand| & \wupperhand \\ +\verb|\bupperhand| & \bupperhand \\ +\verb|\wdecisive| & \wdecisive \\ +\verb|\bdecisive| & \bdecisive \\ +\verb|\equal| & \equal \\ +\verb|\unclear| & \unclear \\ +\verb|\compensation| & \compensation \\ +\verb|\withattack| & \withattack \\ +\verb|\withinit| & \withinit \\ +\verb|\counterplay| & \counterplay \\ +\verb|\zugzwang| & \zugzwang \\ +\verb|\mate| & \mate \\ +\verb|\withidea| & \withidea \\ +\verb|\onlymove| & \onlymove \\ +\verb|\betteris| & \betteris \\ +\verb|\file| & \file \\ +\verb|\diagonal| & \diagonal \\ +\verb|\kside| & \kside \\ +\verb|\qside| & \qside \\ +\verb|\weakpt| & \weakpt \\ +\verb|\bishoppair| & \bishoppair \\ +\verb|\opposbishops| & \opposbishops \\ +\verb|\samebishops| & \samebishops \\ +\verb|\unitedpawns| & \unitedpawns \\ +\verb|\seppawns| & \seppawns \\ +\verb|\doublepawns| & \doublepawns \\ +\verb|\morepawns| & \morepawns \\ +\verb|\timelimit| & \timelimit \\ +\verb|\novelty| & \novelty \\ +\verb|\comment| & \comment \\ +\verb|\various| & \various \\ +\verb|\without| & \without \\ +\verb|\with| & \with \\ +\verb|\etc| & \etc \\ +\verb|\see| & \see \\ +\end{tabular} +\end{document} diff --git a/Master/texmf-dist/doc/latex/skak/font.tex b/Master/texmf-dist/doc/latex/skak/font.tex new file mode 100644 index 00000000000..d126b999e06 --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/font.tex @@ -0,0 +1,32 @@ + + +\documentclass[11pt,twocolumn]{article} + +\usepackage[ps,mover]{skak} + +\title{font\\Verifying that the fonts behave properly} +\author{Torben Hoffmann } + +\begin{document} + +\parindent=0pt + +\maketitle + + +\section{In a section command: \wmove{Nf6}\counterplay} + +\textbf{In bold font:\wmove{Nf6}\counterplay} (\wmove{Nf}\counterplay +in normal thickness.) + +{\Huge In a Huge font: \wmove{Nf6}\counterplay} + + + +\end{document} + + + + + + diff --git a/Master/texmf-dist/doc/latex/skak/games.tex b/Master/texmf-dist/doc/latex/skak/games.tex new file mode 100644 index 00000000000..67dcb264cc5 --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/games.tex @@ -0,0 +1,72 @@ +\documentclass[german, twocolumn,a4paper,twoside,10pt]{article} + +\usepackage{skak} +\usepackage{babel} +\newcommand{\chessgame}[4]{ + \begin{center} + \large{\textbf{#1} -- \textbf{#2}} + + \textsf{#3} + + \small{\textsc{#4}} + \end{center} +} + +\title{Tournament} +\author{Franz Meier} +\begin{document} + +\maketitle + +\chessgame{Hans Schulze}{Franz Meier}{Tournament, 2002}{} +\styleB +\newgame +\mainline{1. d4 d5 2. Nf3 Nf6 3.Bf4 c5 4.e3 Nc6 5.c3} +\[\showboard\] + +\chessgame{Franz Meier}{Gustav Frank}{Tournament, 2002}{K\"{o}nigsindisch} +\styleB +\newgame +\mainline{1. Nf3 Nf6 2. c4 g6 3. Nc3 Bg7 4. e4 d6 5. d4 O-O 6. Be2 e5 7. O-O Nc6 8. d5 Ne7 9. b4 a5 10. Ba3 Nd7 11. bxa5 Rxa5 12. Bb4 Ra8 13. a4 Bh6 14. a5 f5 15. Nd2 Nf6 16.c5 Bxd2 17.Qxd2 fxe4} +\[\showboard\] + + +\chessgame{John Bauer}{Franz Meier}{Tournament, 2002}{Caro-Kann} +\styleB +\newgame +\mainline{1.e4 c6 2.d4 d5 3.Nc3 dxe4 4.Nxe4 Nd7 5.Ng5 Ngf6 6.Bd3 e6 7.N1f3 Bd6 8.Qe2 h6 9.Ne4} +\[\showboard\] + +\chessgame{Franz Meier}{Karl Adams}{Tournament, 2002}{} +\styleB +\newgame +\mainline{1.Nf3 Nf6 2.c4 e6 3.Nc3 d5 4.d4 c6 5.e3 Nbd7} +\[\showboard\] + +\chessgame{Christian Klaus}{Franz Meier}{Tournament, 2002}{} +\styleB +\newgame +\mainline{1.e4 c6 2.d4 d5 3.e5 Bf5 4.Bd3 Bxd3} +\[\showboard\] + +\chessgame{Franz Meier}{Norbert Ludwig}{Tournament, 2002}{Englisch 1. $\dots$ c5} +\styleB +\newgame +\mainline{1.Nf3 c5 2.c4 Nf6 3.Nc3 Nc6 4.g3 d5 5.d4 cxd4 6.Nxd4 dxc4 7.Nxc6 Qxd1+ 8.Nxd1 bxc6 9.Bg2 Nd5 10.Ne3 e6 11.Nxc4 Ba6 12.Na5 Bb4+ 13.Bd2 Bxa5 14.Bxa5 Rb8 +15.b3 Ke7} +\[\showboard\] + +\chessgame{Dieter Klose}{Franz Meier}{Tournament, 2002}{Caro-Kann} +\styleB +\newgame +\mainline{1.e4 c6 2.d4 d5 3.exd5 cxd5 4.c4 Nf6 5.Nc3 e6 6.Nf3 Bb4 7.cxd5 Nxd5 8.Bd2 Nc6 9.Bd3 O-O 10.O-O Be7} +\[\showboard\] + +\chessgame{Franz Meier}{Karl Eich}{Tournament, 2002}{} +\styleB +\newgame +\mainline{1.Nf3 Nf6 2.c4 b6 3.g3 c5 4.Bg2 Bb7 5.O-O} +\[\showboard\] + +\end{document} + diff --git a/Master/texmf-dist/doc/latex/skak/hightest.tex b/Master/texmf-dist/doc/latex/skak/hightest.tex new file mode 100644 index 00000000000..24a4e553cf7 --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/hightest.tex @@ -0,0 +1,309 @@ +%% Name: hightest.tex +%% Author: Dirk Baechle +%% Date: 2003-01-22 + +\documentclass[a4paper, twocolumn]{article} +\usepackage[ps]{skak} +\tinyboard + +\setlength{\parindent}{0pt} + +\def\square#1{\texttt{#1}} +\def\testarrow#1#2{% + \printarrow{#1}{#2} + \mbox{\texttt{(#1 -> #2)}}} + +\def\testknightmove#1#2{% + \printknightmove{#1}{#2} + \mbox{\texttt{(#1 -> #2)}}} + +\pagestyle{empty} + +\begin{document} + +\section{Test of the ``\texttt{highlight}'' command} + +In all following boards there should appear + +\begin{itemize} +\item frames on \square{g1}, \square{f2} and \square{e3} +\item a small cross on \square{a1}, +\item a large cross on \square{a8}, +\item a small circle on \square{h1} and +\item a large circle on \square{h8}. +\end{itemize} + +\subsection{White to move} +\subsubsection{With notation} + +\fenboard{2rr3k/pp3pp1/1nnqbN1p/3pN3/2pP4/2P3Q1/PPB4P/R4RK1 w KQkq - 0 1} +\centerline{\showboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\medskip +\centerline{\showinverseboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\subsubsection{Without notation} +\notationOff + +\centerline{\showboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\medskip +\centerline{\showinverseboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\subsubsection{With mover} +\showmoverOn +\notationOn + +\centerline{\showboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\medskip +\centerline{\showinverseboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\notationOff +\medskip +\centerline{\showboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\medskip +\centerline{\showinverseboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\subsection{Black to move} +\subsubsection{With notation} +\notationOn +\showmoverOff +\fenboard{2rr3k/pp3pp1/1nnqbN1p/3pN3/2pP4/2P3Q1/PPB4P/R4RK1 b KQkq - 0 1} +\centerline{\showboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\medskip +\centerline{\showinverseboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\subsubsection{Without notation} +\notationOff + +\centerline{\showboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\medskip +\centerline{\showinverseboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\subsubsection{With mover} +\showmoverOn +\notationOn + +\centerline{\showboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\medskip +\centerline{\showinverseboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\notationOff +\medskip +\centerline{\showboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\medskip +\centerline{\showinverseboard} +\highlight{g1,f2,e3} +\highlight[x]{a1} +\highlight[X]{a8} +\highlight[o]{h1} +\highlight[O]{h8} + +\section{Test of the ``\texttt{printarrow}'' command} + +%% Init board +\notationOn +\showmoverOff +\fenboard{2rr3k/pp3pp1/1nnqbN1p/3pN3/2pP4/2P3Q1/PPB4P/R4RK1 w KQkq - 0 1} + +\subsection{From lower to upper half} + +\centerline{\showboard} +\testarrow{a1}{a8} +\testarrow{f3}{e6} +\testarrow{g4}{h7} + +\newpage +\centerline{\showinverseboard} +\testarrow{a1}{a8} +\testarrow{f3}{e6} +\testarrow{g4}{h7} + +\subsection{From upper to lower half} +\centerline{\showboard} +\testarrow{h8}{h1} +\testarrow{f7}{c2} +\testarrow{b6}{g3} + +\medskip +\centerline{\showinverseboard} +\testarrow{h8}{h1} +\testarrow{f7}{c2} +\testarrow{b6}{g3} + +\subsection{From left to right half} +\centerline{\showboard} +\testarrow{a1}{h1} +\testarrow{b2}{h8} +\testarrow{c7}{g3} + +\medskip +\centerline{\showinverseboard} +\testarrow{a1}{h1} +\testarrow{b2}{h8} +\testarrow{c7}{g3} + +\subsection{From right to left half} +\centerline{\showboard} +\testarrow{h8}{a8} +\testarrow{g6}{a4} +\testarrow{f3}{c5} + +\medskip +\centerline{\showinverseboard} +\testarrow{h8}{a8} +\testarrow{g6}{a4} +\testarrow{f3}{c5} + +\section{Test of the ``\texttt{printknightmove}'' command} + +\subsection{Upwards} +\centerline{\showboard} +\testknightmove{d4}{b5} +\testknightmove{d4}{c6} +\testknightmove{d4}{e6} +\testknightmove{d4}{f5} + +\medskip +\centerline{\showinverseboard} +\testknightmove{d4}{b5} +\testknightmove{d4}{c6} +\testknightmove{d4}{e6} +\testknightmove{d4}{f5} + +\subsection{Downwards} +\centerline{\showboard} +\testknightmove{e6}{c5} +\testknightmove{e6}{d4} +\testknightmove{e6}{f4} +\testknightmove{e6}{g5} + +\medskip +\centerline{\showinverseboard} +\testknightmove{e6}{c5} +\testknightmove{e6}{d4} +\testknightmove{e6}{f4} +\testknightmove{e6}{g5} + +\subsection{To the right} +\centerline{\showboard} +\testknightmove{b4}{c6} +\testknightmove{b4}{d5} +\testknightmove{b4}{d3} +\testknightmove{b4}{c2} + +\medskip +\centerline{\showinverseboard} +\testknightmove{b4}{c6} +\testknightmove{b4}{d5} +\testknightmove{b4}{d3} +\testknightmove{b4}{c2} + +\subsection{To the left} +\centerline{\showboard} +\testknightmove{f5}{e7} +\testknightmove{f5}{d6} +\testknightmove{f5}{d4} +\testknightmove{f5}{e3} + +\medskip +\centerline{\showinverseboard} +\testknightmove{f5}{e7} +\testknightmove{f5}{d6} +\testknightmove{f5}{d4} +\testknightmove{f5}{e3} + +\subsection{From the corners} +\centerline{\showboard} +\testknightmove{a1}{b3} +\testknightmove{a1}{c2} +\testknightmove{a8}{c7} +\testknightmove{a8}{b6} +\testknightmove{h8}{g6} +\testknightmove{h8}{f7} +\testknightmove{h1}{g3} +\testknightmove{h1}{f2} + +\end{document} + diff --git a/Master/texmf-dist/doc/latex/skak/informator.tex b/Master/texmf-dist/doc/latex/skak/informator.tex new file mode 100644 index 00000000000..737e7529fa5 --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/informator.tex @@ -0,0 +1,83 @@ +\documentclass[a4paper,twocolumn]{article} + +\usepackage{booktabs} +\pagestyle{empty} + + +\usepackage[ps]{skak} +\newcommand{\Cmd}[1]{\textsf{\textbf{\textbackslash#1}}} + +\title{Informator Symbols Available in the \texttt{skak} Package} +\author{Torben Hoffmann} +\begin{document} + +\maketitle + +Dirk B\"achle has been so kind as to create a number of the symbols +used in the Informator. They are now a part of the skak font. + +\begin{tabular}{lc} +\toprule +Command & \multicolumn{1}{l}{Output}\\ \midrule +\Cmd{wbetter} & \wbetter \\ +\Cmd{bbetter} & \bbetter \\ +\Cmd{wupperhand} & \wupperhand \\ +\Cmd{bupperhand} & \bupperhand \\ +\Cmd{wdecisive} & \wdecisive \\ +\Cmd{bdecisive} & \bdecisive \\ +\Cmd{equal} & \equal \\ +\Cmd{unclear} & \unclear \\ +\Cmd{compensation} & \compensation \\ +\Cmd{devadvantage} & \devadvantage \\ +\Cmd{moreroom} & \moreroom \\ +\Cmd{withattack} & \withattack \\ +\Cmd{withinit} & \withinit \\ +\Cmd{counterplay} & \counterplay \\ +\Cmd{zugzwang} & \zugzwang \\ +\Cmd{mate} & \mate \\ +\Cmd{withidea} & \withidea \\ +\Cmd{onlymove} & \onlymove \\ +\Cmd{betteris} & \betteris \\ +\Cmd{file} & \file \\ +\Cmd{diagonal} & \diagonal \\ +\Cmd{centre} & \centre \\ +\Cmd{kside} & \kside \\ +\Cmd{qside} & \qside \\ +\bottomrule +\end{tabular} + + +\begin{tabular}{lc} +\toprule +Command & \multicolumn{1}{l}{Output}\\ \midrule + +\Cmd{weakpt} & \weakpt \\ +\Cmd{ending} & \ending \\ + + +\Cmd{bishoppair} & \bishoppair \\ +\Cmd{opposbishops} & \opposbishops \\ +\Cmd{samebishops} & \samebishops \\ + +\Cmd{unitedpawns} & \unitedpawns \\ +\Cmd{seppawns} & \seppawns \\ +\Cmd{doublepawns} & \doublepawns \\ +\Cmd{passedpawn} & \passedpawn \\ +\Cmd{morepawns} & \morepawns \\ +\Cmd{timelimit} & \timelimit \\ +\Cmd{novelty} & \novelty \\ +\Cmd{comment} & \comment \\ +\Cmd{various} & \various \\ +\Cmd{without} & \without \\ +\Cmd{with} & \with \\ +\Cmd{etc} & \etc \\ +\Cmd{see} & \see \\ + +\Cmd{markera} & \markera \\ +\Cmd{markerb} & \markerb \\ +\bottomrule +\end{tabular} + + + +\end{document} diff --git a/Master/texmf-dist/doc/latex/skak/ingo-bug1.tex b/Master/texmf-dist/doc/latex/skak/ingo-bug1.tex new file mode 100644 index 00000000000..bc0ef9508a4 --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/ingo-bug1.tex @@ -0,0 +1,21 @@ +\documentclass[german,twocolumn]{article} + +\usepackage{skak} +\usepackage[german]{babel} + + +\begin{document} + +\styleC +\newgame + +\mainline{1. Nf3 Nf6 2. c4 g6 3. Nc3 Bg7 4. e4 d6 5.d4 O-O 6. Be2 e5 + 7. O-O Nc6 8. d5 Ne7 9. b4 a5 10. Ba3 Nd7 11. bxa5 Rxa5 12. Bb4 Ra8 + 13. a4 Bh6 14. a5 f5 15. Nd2 Nf6 16.c5 Bxd2 17.Qxd2 fxe4} + + +\[\showboard\] + + + +\end{document} diff --git a/Master/texmf-dist/doc/latex/skak/lambda.tex b/Master/texmf-dist/doc/latex/skak/lambda.tex new file mode 100644 index 00000000000..5285e9a5104 --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/lambda.tex @@ -0,0 +1,1146 @@ +% Filename: Lambda.tex +% Author: Alan Jeffrey +% Last modified: 11 May 1990 +% +% Copyright (c) 1990 Alan Jeffrey. Permission is granted to Tugboat +% to publish any or all of this. +% +% A keyboard check: +% +% @ # $ % ^ & * ~ at hash dollar percent caret ampersand asterisk tilde +% : ; , . colon semicolon comma period +% ? ! question-mark exclamation-mark +% " ' ` double-quote apostrophe back-quote +% ( ) { } [ ] parentheses braces square-brackets +% - + = / \ minus plus equals forward-slash backslash +% _ | < > underscore vertical-bar less-than greater-than +% + +\documentstyle[ltugboat,Lambda]{article} + +% This document defines a whole load of extra commands, some of which +% over-ride how LaTeX normally lays things out. For example, ~ is +% redefined to give a hairspace in math mode. This whole document +% should probably be put in a group to stop it getting in the way +% of other articles' macros. + +\title{Lists in \TeX's Mouth} + +\author{Alan Jeffrey} + +\address{Programming Research Group\\ + Oxford University\\ + 11 Keble Road\\ + Oxford OX1 3QD} + +\netaddress{Alan.Jeffrey@uk.ac.oxford.prg} + +\makeatletter + +% The mathcodes for the letters A, ..., Z, a, ..., z are changed to +% generate text italic rather than math italic by default. This makes +% multi-letter names look neater. The mathcode for character 'c' +% is set to "7000 (variable family) + "400 (text italic) + c. +% +% This neat bit of code is due to Mike Spivey. + +\def\@setmcodes#1#2#3{{\count0=#1 \count1=#3 + \loop \global\mathcode\count0=\count1 \ifnum \count0<#2 + \advance\count0 by1 \advance\count1 by1 \repeat}} + +\@setmcodes{`A}{`Z}{"7441} +\@setmcodes{`a}{`z}{"7461} + +\def\Number#1{\csname Number-#1\endcsname} +\def\Label#1{\csname Label-#1\endcsname} + +\newcount\Lastnum + +\def\Forward#1% + {\global\advance\Lastnum by 1 + \csnameafter\xdef{Number-#1}% + {\the\Lastnum}% + \csnameafter\xdef{Label-\the\Lastnum}% + {\@currentlabel}} + +\def\csnameafter#1#2% + {\expandafter#1\csname#2\endcsname} + +\def\Bylist#1% + {\Map\Label + {\Insertsort\Lessthan + {\Map\Number{#1}}}} + +\def\By{\Show\Bylist} + +\let\bindspace=~ +\def~{\ifmmode \, \else \bindspace \fi} + +\def\start#1{\lefteqn{#1}\quad\\} + +\def\nil{[\,\,]} + +\newtheorem{fact}{Fact} +\def\thefact{\@roman\c@fact} + +\def\cstok#1{\leavevmode\thinspace\hbox{\vrule\vtop{\vbox{\hrule\kern1pt + \hbox{\vphantom{\tt/}\thinspace{\tt#1}\thinspace}}% + \kern1pt\hrule}\vrule}\thinspace} + +\begingroup \catcode `|=0 \catcode `[= 1 +\catcode`]=2 \catcode `\{=12 \catcode `\}=12 +\catcode`\\=12 |gdef|@xTeXcode#1\end{TeXcode}[#1|end[TeXcode]] +|endgroup + +\def\TeXcode + {\@verbatim \smallskip\hrule\medskip \frenchspacing\@vobeyspaces \@xTeXcode} +\def\endTeXcode + {\medskip\hrule\smallskip\endtrivlist} + +\makeatother + +\begin{document} + +\maketitle + +\section{Why lists?} + +Originally, I wanted lists in \TeX\ for +a paper I was writing which contained a lot of facts. +\begin{fact} +\Forward{Fac-cows} + Cows have four legs. +\end{fact} +\begin{fact} +\Forward{Fac-people} + People have two legs. +\end{fact} +\begin{fact} +\Forward{Fac-yawn} + Lots of facts in a row can be dull. +\end{fact} +These are generated with commands like +\begin{verbatim} +\begin{fact} +\Forward{Fac-yawn} + Lots of facts in a row can be dull. +\end{fact} +\end{verbatim} +I can then refer to these facts by saying +\begin{verbatim} +\By[Fac-yawn,Fac-cows,Fac-people] +\end{verbatim} +to get +\By[Fac-yawn,Fac-cows,Fac-people]. +And as if by magic, the facts come out sorted, rather than in +the jumbled order I typed them. This is very useful, as I can +reorganize my document to my heart's content, and not have to worry +about getting my facts straight. + +Originally I tried programming this sorting routine in \TeX's +list macros, from Appendix~D of \TB, but I soon ran into trouble. +The problem is that all the Appendix~D macros work by assigning +values to macros. For example: +\begin{verbatim} +\concatenate\foo=\bar\baz +\end{verbatim} +expands out to +\begin{verbatim} +\ta=\expandafter{\bar} +\tb=\expandafter{\baz} +\edef\foo{\the\ta\the\tb} +\end{verbatim} +which assigns the macro \verb|\foo| the contents of \verb|\bar| +followed by the contents of \verb|\baz|. Programming sorting routines +(which are usually recursive) in terms of these lists became rather +painful, as I was constantly having to watch out for local variables, +worrying about what happened if a local variable had the same name +as a global one, and generally having a hard time. + +Then I had one of those ``flash of light'' experiences --- +``You can do lambda-calculus in \TeX,'' I thought, +and since you can do lists directly in lambda calculus, +you should be able to do lists straightforwardly in \TeX. And so you +can. Well, fairly straightforwardly anyway. + +So I went and did a bit of mathematics, and derived the \TeX\ macros +you see here. They were formally verified, and worked first time +(modulo typing errors, of which there were two). + +\section{\TeX's mouth and \TeX's stomach} + +\TeX's programming facilities come in two forms --- there are \TeX's +{\em macros\/} which are expanded in its mouth, and some additional +{\em assignment\/} operations like \verb|\def| which take place in the +stomach. \TeX\ can often spring surprises on you as exactly what +gets evaluated where. +For example, in \LaTeX\ I can put down a +label by saying \verb|\label{Here}|. +\label{Here} +Then I can refer back to that label by saying +\verb|Section~\ref{Here}|, which +produces Section~\ref{Here}. Unfortunately, \verb|\ref{Here}| does +{\em not\/} expand out to {\tt\ref{Here}}! Instead, it expands out to: +\begin{verbatim} +\edef\@tempa{\@nameuse{r@Here}} +\expandafter\@car\@tempa\@nil\null +\end{verbatim} +This means that I can't say +\begin{verbatim} +\ifnum\ref{Here}<4 Hello\fi +\end{verbatim} +and hope that this will expand out to Hello. Instead I +get an error message. Which is rather a pity, as \TeX's mouth is +quite a powerful programming language (as powerful as a Turing Machine in +fact). + +\section{Functions} + +A {\em function\/} is a mathematical object that takes in an argument +(which could well be another function) and returns some other mathematical +object. For example the function $Not$ takes in a boolean and returns +its complement. I'll write function application without brackets, +so $Not~b$ is the boolean complement of $b$. + +Function application +binds to the left, so $f~a~b$ is $(f~a)~b$ rather than $f~(a~b)$. +For example, $Or~a~b$ is the boolean or of $a$ and $b$, and +$Or~True$ is a perfectly good function that takes in a boolean +and returns $True$. + +The obvious equivalents of functions in \TeX\ are macros --- +if I define a function $Foo$ to be: +\begin{eqnarray*} + Foo~x & = & True +\end{eqnarray*} +then it can be translated into \TeX\ as: +\begin{verbatim} +\def\Foo#1{\True} +\end{verbatim} +So where $Foo$ is a function that takes in one argument, \verb|\Foo| +is a macro that takes in one parameter. Nothing has changed except +the jargon and the font. \TeX\ macros can even be partially applied, +for example if we defined: +\begin{eqnarray*} + Baz & = & Or~True +\end{eqnarray*} +then the \TeX\ equivalent would be +\begin{verbatim} +\def\Baz{\Or\True} +\end{verbatim} +Once \verb|\Baz| is expanded, it will expect to be given a parameter, +but when we are defining things, we can go around partially applying +them all we like. + +Here, I'm using $=$ without formally defining it, which is rather +naughty. If I say $x = y$, this means +``given enough parameters, $x$ and $y$ will eventually +expand out to the same thing.'' For example $Foo = Baz$, because +for any $x$, +\begin{eqnarray*} + \start{Foo~x} + & = & True \\ + & = & Or~True~x \\ + & = & Baz~x +\end{eqnarray*} +Normally, functions have to {respect equality\/} which means that: +\begin{itemize} +\item if $x = y$ then $f~x = f~y$, and +\item if $x$ respects equality, then $f~x$ respects equality. +\end{itemize} +However, some \TeX\ control sequences don't obey this. For example, +\verb|\string\Foo| and \verb|\string\Baz| are different, even though +$Foo = Baz$. Hence $string$ doesn't respect equality. +Unless otherwise stated, we won't assume functions respect equality, +although all the functions defined here do. + +All of our functions have capital letters, so that their \TeX\ equivalents +(\verb|\Not|, \verb|\Or| and so on) don't clash with standard \TeX\ or +\LaTeX\ macros. + +\subsection{Identity} + +The simplest function is the {\em identity\/} function, called +$Identity$ funnily enough, which is defined: +\begin{eqnarray*} + Identity~x & = & \Identity{x} +\end{eqnarray*} +This, it must be admitted, is a pretty dull function, but +it's a useful basic combinator. It can be implemented +in \TeX\ quite simply. +\begin{TeXcode} +\def\Identity#1{#1} +\end{TeXcode} +The rules around this definition mean that it is actually part of +\verb|Lambda.sty| and not just another example. + +\subsection{Error} + +Whereas $Identity$ does nothing in a fairly pleasant sort of way, +$Error$ does nothing in a particularly brutal and harsh fashion. +Mathematically, $Error$ is the function that destroys everything +else in front of it. It is often written as $\perp$. +\begin{eqnarray*} + Error~x & = & Error +\end{eqnarray*} +In practice, destroying the entire document when we hit one error +is a bit much, so we'll just print out an error message. +The user can carry on past an error at their own risk, as the code +will no longer be formally verified. +\begin{TeXcode} +\def\Error + {\errmessage{Abandon verification all + ye who enter here}} +\end{TeXcode} +Maybe this function ought to return a more useful error message \ldots + +\subsection{First and Second} + +Two other basic functions are $First$ and $Second$, both of which +take in two arguments, and do the obvious thing. They are defined: +\begin{eqnarray*} + First~x~y & = & x \\ + Second~x~y & = & y +\end{eqnarray*} +We could, in +fact, define $Second$ in terms of $Identity$ and $First$. +For any $x$ and $y$, +\begin{eqnarray*} + \start{First~Identity~x~y} + & = & Identity~y \\ + & = & y \\ + & = & Second~x~y +\end{eqnarray*} +So $First~Identity = Second$. This means that anywhere in our \TeX\ code +we have \verb|\First\Identity| we could replace it by \verb|\Second|. +This is perhaps not the most astonishing \TeX\ fact known to humanity, +but this sort of proof did enable more complex bits of \TeX\ to be +verified before they were run. + +The \TeX\ definitions of \verb|\First| and \verb|\Second| are pretty +obvious. +\begin{TeXcode} +\def\First#1#2{#1} +\def\Second#1#2{#2} +\end{TeXcode} +Note that in \TeX\, \verb|\First\foo\bar| expands out to +\verb|\foo| {\em without\/} expanding out \verb|\bar|. +This is very useful, as we can write macros that would take +forever and a day to run if they expanded all their arguments, +but which actually terminate quite quickly. This is called +{\em lazy evaluation\/} by the functional programming community. + +\subsection{Compose} + +Given two functions $f$ and $g$ we would like to be able to {\em compose\/} +them to produce a function that first applies $g$ then applies $f$. +Normally, this is written as $f \circ g$, but unfortunately \TeX\ doesn't +have infix functions, so we'll have to write it $Compose~f~g$. +\begin{eqnarray*} + Compose~f~g~x & = & f~(g~x) +\end{eqnarray*} +>From this definition, we can deduce that $Compose$ is associative: +\begin{eqnarray*} + \start{Compose~(Compose~f~g)~h} + & = & Compose~f~(Compose~g~h) +\end{eqnarray*} +and $Identity$ is the left unit of $Compose$: +\begin{eqnarray*} + Compose~Identity~f & = & f +\end{eqnarray*} +The reader may wonder why $Identity$ is called a {\em left\/} unit +even though it occurs on the right of the $Compose$ --- this is a side-effect +of using prefix notations where infix is more normal. The infix version +of this equation is: +\begin{eqnarray*} + Identity \circ f & = & f +\end{eqnarray*} +so $Identity$ is indeed on the left of the composition. + +$Compose$ can be implemented in \TeX\ as +\begin{TeXcode} +\def\Compose#1#2#3{#1{#2{#3}}} +\end{TeXcode} + +\subsection{Twiddle} + +Yet another useful little function is $Twiddle$, which takes in +a function and reverses the order that function takes its (first two) +arguments. +\begin{eqnarray*} + Twiddle~f~x~y & = & f~y~x +\end{eqnarray*} +Again, there aren't many immediate uses for such a function, but it'll +come in handy later on. It satisfies the properties +\begin{eqnarray*} + Twiddle~First & = & Second \\ + Twiddle~Second & = & First \\ + Compose~Twiddle~Twiddle & = & Identity +\end{eqnarray*} +Its \TeX\ equivalent is +\begin{TeXcode} +\def\Twiddle#1#2#3{#1{#3}{#2}} +\end{TeXcode} +This function is called ``twiddle'' because it is sometimes written +$\widetilde f$ (and $\sim$ is pronounced ``twiddle''). +It also twiddles its arguments around, +which is quite nice if your sense of humour runs to appalling puns. + +\section{Booleans} + +As we're trying to program a sorting routine, it would be nice to +be able to define orderings on things, and to do this we need some +representation of boolean variables. Unfortunately \TeX\ doesn't have a type +for booleans, so we'll have to invent our own. We'll +implement a boolean as a function $b$ of the form +\begin{eqnarray*} + b~x~y & + = & + \left\{ + \begin{array}{ll} + x & \mbox{if $b$ is true} \\ + y & \mbox{otherwise} + \end{array} + \right. +\end{eqnarray*} +More formally, a +boolean $b$ is a function which respects equality, +such that for all $f$, $g$ and $z$: +\begin{eqnarray*} + b~f~g~z & = & b~(f~z)~(g~z) +\end{eqnarray*} +and for all $f$ and $g$ which respect equality, +\begin{eqnarray*} + b~(f~b)~(g~b) & = & b~(f~First)~(g~Second) +\end{eqnarray*} +All the functions in this section satisfy these properties. Surprisingly +enough, so does $Error$, which is quite useful, as it allows us to +reason about booleans which ``go wrong''. + +\subsection{True, False and Not} + +Since we are implementing booleans as functions, we already have the +definitions of $True$, $False$ and $Not$. +\begin{eqnarray*} + True & = & First \\ + False & = & Second \\ + Not & = & Twiddle +\end{eqnarray*} +So for free we get the following results: +\begin{eqnarray*} + Not~True & = & False \\ + Not~False & = & True \\ + Compose~Not~Not & = & Identity +\end{eqnarray*} +The \TeX\ implementation is not exactly difficult: +\begin{TeXcode} +\let\True=\First +\let\False=\Second +\let\Not=\Twiddle +\end{TeXcode} + +\subsection{And and Or} + +The definitions of $And$ and $Or$ are: +\begin{eqnarray*} + And~a~b & + = & + \left\{ + \begin{array}{ll} + b & \mbox{if $a$ is true} \\ + False & \mbox{otherwise} + \end{array} + \right. + \\ + Or~a~b & + = & + \left\{ + \begin{array}{ll} + True & \mbox{if $a$ is true} \\ + b & \mbox{otherwise} + \end{array} + \right. +\end{eqnarray*} +With our definition of what a boolean is, this is just the same as +\begin{eqnarray*} + And~a~b & = & a~b~False \\ + Or~a~b & = & a~True~b +\end{eqnarray*} +>From these conditions, we can show that $And$ is associative, and +has left unit $True$ and left zeros $False$ and $Error$: +\begin{eqnarray*} + And~(And~a~b)~c & = & And~a~(And~b~c) \\ + And~True~b & = & b \\ + And~False~b & = & False \\ + And~Error~b & = & Error +\end{eqnarray*} +$Or$ is associative, has left unit $False$ and left zeros $True$ and $Error$: +\begin{eqnarray*} + Or~(Or~a~b)~c & = & Or~a~(Or~b~c) \\ + Or~False~b & = & b \\ + Or~True~b & = & True \\ + Or~Error~b & = & Error +\end{eqnarray*} +De~Morgan's laws hold: +\begin{eqnarray*} + Not~(And~a~b) & = & Or~(Not~a)~(Not~b) \\ + Not~(Or~a~b) & = & And~(Not~a)~(Not~b) +\end{eqnarray*} +and $And$ and $Or$ left-distribute through one another: +\begin{eqnarray*} + Or~a~(And~b~c) & = & And~(Or~a~b)~(Or~a~c) \\ + And~a~(Or~b~c) & = & Or~(And~a~b)~(And~a~c) +\end{eqnarray*} +$And$ and $Or$ are {\em not\/} commutative, though. For example, +\begin{eqnarray*} + \start{Or~True~Error} + & = & True~True~Error \\ + & = & True +\end{eqnarray*} +but +\begin{eqnarray*} + \start{Or~Error~True} + & = & Error~True~True \\ + & = & Error +\end{eqnarray*} +This is actually quite useful since there are some booleans that +need to return an error occasionally. If $a$ is $True$ when $b$ +is safe (i.e.\ doesn't become $Error$) and is $False$ otherwise, we can +say $Or~a~b$ and know we're not going to get an error. This is handy +for things like checking for division by zero, or trying to get the +first element of an empty list. + +Similarly, because of the possibility of $Error$, +$And$ and $Or$ don't right-distribute through each other, +as +\begin{eqnarray*} + \start{Or~(And~False~Error)~True} + & \ne & And~(Or~False~True)~(Or~Error~True) +\end{eqnarray*} +As errors shouldn't crop up, this needn't worry us too much. +\begin{TeXcode} +\def\And#1#2{#1{#2}\False} +\def\Or#1#2{#1\True{#2}} +\end{TeXcode} + +\subsection{Lift} + +Quite a lot of the time we won't be dealing with booleans, but with +{\em predicates}, which are just functions that return a boolean. +For example, the predicate $Lessthan$ is defined below so that +$Lessthan~i~j$ is true whenever $i<j$. +Given a predicate $p$ we would like to be able to +{\em lift\/} it to $Lift~p$, defined: +\begin{eqnarray*} + Lift~p~f~g~x & = & p~x~f~g~x +\end{eqnarray*} +For example, $Lift~(Lessthan~0)~f~g$ takes in a number and applies +$f$ to it if it is positive and $g$ to it otherwise. This is quite +useful for defining functions. +\begin{TeXcode} +\def\Lift#1#2#3#4{#1{#4}{#2}{#3}{#4}} +\end{TeXcode} + +\subsection{Lessthan and \TeX if} + +Finally, we would like to be able to use \TeX's built-in booleans +as well as our own. For example, we would like a predicate +$Lessthan$ such that: +\begin{eqnarray*} + Lessthan~i~j & + = & + \left\{ + \begin{array}{ll} + True & \mbox{if } i < j \\ + False & \mbox{if } i \ge j \\ + Error & \mbox{otherwise} + \end{array} + \right. +\end{eqnarray*} +The $Error$ condition happens if we try applying $Lessthan$ to something +that isn't a number --- $Lessthan~True~False$ is $Error$% +\footnote + {Actually, that's a little white lie --- trying to persuade \TeX\ to + do run-time type checking isn't much fun. So the \TeX\ implementation + of this is actually a {\em refinement\/} where the $Error$ condition + has been replaced by whatever it is \TeX\ does if you try doing + {\tt\string\ifnum $x$ < $y$} when $x$ and $y$ aren't numbers}. +This is fine as a mathematical definition, but how will +we implement it? If we assume we have a macro \verb|\TeXif|, +which converts \TeX\ if-statements into booleans, we could just +define: +\begin{TeXcode} +\def\Lessthan#1#2{\TeXif{\ifnum#1<#2 }} +\end{TeXcode} +So the question is just how to define \verb|\TeXif|. +Unfortunately, the ``obvious'' code does not work: +\begin{verbatim} +\def\TeXif#1#2#3{#1#2\else#3\fi} +\end{verbatim} +For example, \verb|\TeXif\iftrue\True\True| doesn't expand out to +\verb|\True|. Instead, it expands as: +\begin{verbatim} +\TeXif\iftrue\True\True + = \iftrue\True\else\True\fi + = \True\else\True\fi + = \else\fi + = +\end{verbatim} +Another common \TeX nique is to use a macro \verb|\next| to +be the expansion text: +\begin{verbatim} +\def\TeXif#1#2#3% + {#1\def\next{#2}\else\def\next{#3}\fi + \next} +\end{verbatim} +However, this uses \TeX's stomach to do the \verb|\def|, and we are +trying to do this using only the mouth. One (slightly tricky) solution +is to use pattern-matching to gobble up the offending \verb|\else| and/or +\verb|\fi|. +\begin{TeXcode} +\def\gobblefalse\else\gobbletrue\fi#1#2% + {\fi#1} +\def\gobbletrue\fi#1#2% + {\fi#2} +\def\TeXif#1% + {#1\gobblefalse\else\gobbletrue\fi} +\end{TeXcode} +So if the \TeX\ if-statement is true, \verb|\gobblefalse| gobbles +up the false-text, otherwise \verb|\gobbletrue| gobbles up the +true-text. For example, +\begin{verbatim} +\TeXif\iftrue\True\True + = \iftrue\gobblefalse\else + \gobbletrue\fi\True\True + = \gobblefalse\else + \gobbletrue\fi\True\True + = \fi\True + = \True +\end{verbatim} +Phew. And so we have booleans. + +\section{Lists} + +A list is a (possibly infinite) sequence of values. For example, +the list $[1,2,3]$ contains three numbers, the list $\nil$ contains +none, and the list $[1,2,3,\ldots]$ contains infinitely many. +A list is either {\em empty\/} (written $\nil$) or is comprised +of a {\em head\/} +$x$ and a {\em tail\/} $xs$ (in which case it's written $x:xs$). +For example, $1:2:3:\nil$ is $[1,2,3]$. + +In a similar fashion to the implementation of booleans, +a list $xs$ is implemented as a function of the form +\begin{eqnarray*} + xs~f~e & + = & + \left\{ + \begin{array}{ll} + e & \mbox{if $xs$ is empty} \\ + f~y~ys & \mbox{if $xs$ has head $y$ and tail $ys$} + \end{array} + \right. +\end{eqnarray*} +Again, we are implementing a datatype as a function, a quite powerful +trick, just not one usually seen in \TeX. We will assume that +whenever a list $x:xs$ is applied to $f$ and $e$, $f~x$ respects equality. +This allows us to assume that if $xs = ys$ then $x:xs = x:ys$, +which is handy. + +\subsection{Nil, Cons, Stream and Singleton} + +The simplest list is $Nil$, the empty list which we have been writing +$\nil$. +\begin{eqnarray*} + Nil & = & Second +\end{eqnarray*} +The other possible list is $Cons~x~xs$, which has head $x$ and tail $xs$. +\begin{eqnarray*} + Cons~x~xs~f~e & = & f~x~xs +\end{eqnarray*} +Every list can be constructed using these functions. +The list $[1,2,3]$ is $Cons~1~(Cons~2~(Cons~3~Nil))$, and the +list $[a,a,a,\ldots]$ is $Stream~a$ where $Stream$ is defined: +\begin{eqnarray*} + Stream~a & = & Cons~a~(Stream~a) +\end{eqnarray*} +There's even at least one application for infinite lists, +as we'll see in Section~\ref{outputroutines}. + +The singleton list $[a]$ is $Singleton~a$, defined as: +\begin{eqnarray*} + Singleton~a & = & Cons~a~Nil +\end{eqnarray*} +These all have straightforward \TeX\ definitions. +\begin{TeXcode} +\let\Nil=\Second +\def\Cons#1#2#3#4{#3{#1}{#2}} +\def\Stream#1{\Cons{#1}{\Stream{#1}}} +\def\Singleton#1{\Cons{#1}\Nil} +\end{TeXcode} + +\subsection{Head and Tail} + +So, we can construct any list we like, but we still can't get any information +out of it. To begin with, we'd like to be able to get the head +and tail of a list. +\begin{eqnarray*} + Head~xs & = & xs~First~Error \\ + Tail~xs & = & xs~Second~Error +\end{eqnarray*} +For example, the tail of $x:xs$ is +\begin{eqnarray*} + \start{Tail~(Cons~x~xs)} + & = & Cons~x~xs~Second~Error \\ + & = & Second~x~xs \\ + & = & \Tail{\Cons{x}{xs}} +\end{eqnarray*} +The tail of $\nil$ is, as one would expect, +\begin{eqnarray*} + \start{Tail~Nil} + & = & Nil~Second~Error \\ + & = & Error +\end{eqnarray*} +And the head of $Stream~a$ is +\begin{eqnarray*} + \start{Head~(Stream~a)} + & = & Stream~a~First~Error \\ + & = & Cons~a~(Stream~a)~First~Error \\ + & = & First~a~(Stream~a) \\ + & = & \Head{\Stream{a}} +\end{eqnarray*} +So we can get the head of an infinite list in finite time. This is +fortunate, as otherwise there wouldn't be much point in allowing +infinite objects. +\begin{TeXcode} +\def\Head#1{#1\First\Error} +\def\Tail#1{#1\Second\Error} +\end{TeXcode} + +\subsection{Foldl and Foldr} + +Using $Head$ and $Tail$ we can get at the beginning of any non-empty list, +but in general we need more information than that. Rather than write +a whole bunch of recursive functions on lists, I'll implement two +fairly general functions, with which we can implement (almost) everything +else. + +$Foldl$ and $Foldr$ both take in functions and apply them recursively +to a list. $Foldl$ starts at the left of the list, and $Foldr$ +starts at the right. For example, +\begin{eqnarray*} + Foldl~f~e~[1,2,3] & = & f~(f~(f~e~1)~2)~3 \\ + Foldr~f~e~[1,2,3] & = & f~1~(f~2~(f~3~e)) +\end{eqnarray*} +These functions will be used a lot later on. $Foldl$ can be defined: +\begin{eqnarray*} + Foldl~f~e~xs & = & xs~(Foldl'~f~e)~e \\ + Foldl'~f~e~x~xs & = & Foldl~f~(f~e~x)~xs +\end{eqnarray*} +So $Foldl~f~e~\nil$ is +\begin{eqnarray*} + \start{Foldl~f~e~Nil} + & = & Nil~(Foldl'~f~e)~e \\ + & = & \Foldl{f}{e}\Nil +\end{eqnarray*} +And $Foldl~f~e~(x:xs)$ is +\begin{eqnarray*} + \start{Foldl~f~e~(Cons~x~xs)} + & = & Cons~x~xs~(Foldl'~f~e)~e \\ + & = & Foldl'~f~e~x~xs \\ + & = & Foldl~f~(f~e~x)~xs +\end{eqnarray*} +For example, $Foldl~f~e~[1,2,3]$ is +\begin{eqnarray*} + \start{Foldl~f~e~[1,2,3]} + & = & Foldl~f~(f~e~1)~[2,3] \\ + & = & Foldl~f~(f~(f~e~1)~2)~[3] \\ + & = & Foldl~f~(f~(f~(f~e~1)~2)~3)~\nil \\ + & = & f~(f~(f~e~1)~2)~3 +\end{eqnarray*} +as promised. Similarly, we can define $Foldr$ as +\begin{eqnarray*} + Foldr~f~e~xs & = & xs~(Foldr'~f~e)~e \\ + Foldr'~f~e~x~xs & = & f~x~(Foldr~f~e~xs) +\end{eqnarray*} +For $Foldr~f$ to respect equality, $f~x$ should respect equality. + +When we do the unfolding, we discover that +\begin{eqnarray*} + Foldr~f~e~\nil & = & e \\ + Foldr~f~e~(x:xs) & = & f~e~(Foldr~f~e~xs) +\end{eqnarray*} +$Foldr$ tends to be more efficient than $Foldl$, because $Foldl$ +has to run along the entire list before it can start applying $f$, +whereas $Foldr$ can apply $f$ straight away. If $f$ is a lazy function, +this can make quite a difference. $Foldl$ on infinite lists, anyone? +\begin{TeXcode} +\def\Foldl#1#2#3% + {#3{\Foldl@{#1}{#2}}{#2}} +\def\Foldl@#1#2#3#4% + {\Foldl{#1}{#1{#2}{#3}}{#4}} +\def\Foldr#1#2#3% + {#3{\Foldr@{#1}{#2}}{#2}} +\def\Foldr@#1#2#3#4% + {#1{#3}{\Foldr{#1}{#2}{#4}}} +\end{TeXcode} + +\subsection{Cat} + +Given two lists, we would like to be able to stick them together, +which is what $Cat$ (short for ``concatenate'') +does. For example, $Cat~[1,2]~[3,4]$ is +$[1,2,3,4]$. It can be defined using $Foldr$: +\begin{eqnarray*} + Cat~xs~ys & = & Foldr~Cons~ys~xs +\end{eqnarray*} +So +\begin{eqnarray*} + \start{Cat~[1,2]~[3,4]} + & = & Foldr~Cons~[3,4]~[1,2] \\ + & = & Cons~1~(Foldr~Cons~[3,4]~[2]) \\ + & = & Cons~1~(Cons~2~(Foldr~Cons~[3,4]~\nil)) \\ + & = & Cons~1~(Cons~2~[3,4]) \\ + & = & \Unlistize{\Cat{\Listize[1,2]}{\Listize[3,4]}} +\end{eqnarray*} +The \TeX\ code for \verb|\Cat| is suspiciously similar to its mathematical +definition. +\begin{TeXcode} +\def\Cat#1#2{\Foldr\Cons{#2}{#1}} +\end{TeXcode} + +\subsection{Reverse} + +We can reverse any list with the function $Reverse$, defined using +$Foldl$: +\begin{eqnarray*} + Reverse & = & Foldl~(Twiddle~Cons)~Nil +\end{eqnarray*} +For example, $Reverse~[1,2,3]$ can be calculated: +\begin{eqnarray*} + \start{Reverse~[1,2,3]} + & = & Foldl~(Twiddle~Cons)~Nil~[1,2,3] \\ + & = & Twiddle~Cons \\ + & & \quad (Twiddle~Cons~(Twiddle~Cons~Nil~1)~2)~3 \\ + & = & Cons~3~(Cons~2~(Cons~1~Nil)) \\ + & = & \Show\Reverse[1,2,3] +\end{eqnarray*} +The \TeX\ code for \verb|\Reverse| doesn't even take in any parameters. +\begin{TeXcode} +\def\Reverse{\Foldl{\Twiddle\Cons}\Nil} +\end{TeXcode} + +\subsection{All, Some and Isempty} + +Given a predicate $p$, we can find out if all the elements of +a list satisfy $p$ with $All~p$. Similarly we can find if something +in the list satisfies $p$ with $Some~p$. For example, +\begin{eqnarray*} + All~(Lessthan~1)~[1,2,3] + & = & \All{\Lessthan 1}{\Listize[1,2,3]}{True}{False} \\ + Some~(Lessthan~1)~[1,2,3] + & = & \Some{\Lessthan 1}{\Listize[1,2,3]}{True}{False} +\end{eqnarray*} +These can be defined +\begin{eqnarray*} + All~p & = & Foldr~(Compose~And~p)~True \\ + Some~p & = & Foldr~(Compose~Or~p)~False +\end{eqnarray*} +For example, $Isempty$ can be defined +\begin{eqnarray*} + Isempty & = & All~(First~False) +\end{eqnarray*} +This is probably not the most efficient check in the world, but we +hardly ever need it --- $Foldl$ or $Foldr$ will normally do the job. +\begin{TeXcode} +\def\All#1{\Foldr{\Compose\And{#1}}\True} +\def\Some#1{\Foldr{\Compose\Or{#1}}\False} +\def\Isempty{\All{\First\False}} +\end{TeXcode} + +\subsection{Filter} + +$Filter$ takes a predicate $p$ and a list $xs$, and returns a list +containing only those elements of $xs$ that satisfy $p$. For example, +\begin{eqnarray*} + Filter~(Lessthan~1)~[1,2,3] & = & \Show\Filter{\Lessthan 1}[1,2,3] +\end{eqnarray*} +$Filter$ can be defined as a $Foldr$: +\begin{eqnarray*} + Filter~p & = & Foldr~(Lift~p~Cons~Second)~Nil +\end{eqnarray*} +Another easy bit of \TeX: +\begin{TeXcode} +\def\Filter#1% + {\Foldr{\Lift{#1}\Cons\Second}\Nil} +\end{TeXcode} + +\subsection{Map} + +$Map$ takes a function $f$ and a list $xs$ and applies $f$ to every +element of $xs$. For example, +\begin{eqnarray*} + Map~f~[1,2,3] & = & \Show\Map{f~}[1,2,3] +\end{eqnarray*} +This is another job for $Foldr$. +\begin{eqnarray*} + Map~f & = & Foldr~(Compose~Cons~f)~Nil +\end{eqnarray*} +We shall see $Map$ used later on, to convert from a list of +names such as \Show\Map{\Compose\mbox\tt}[Fac-yawn,Fac-cows], to a list of +labels such as \By[Fac-yawn,Fac-cows]. +\begin{TeXcode} +\def\Map#1{\Foldr{\Compose\Cons{#1}}\Nil} +\end{TeXcode} + +\subsection{Insert} + +The only function we need which isn't easily defined as a reduction +is $Insert$, which inserts an element into a sorted list. For example, +\begin{eqnarray*} + Insert~Lessthan~3~[1,2,4,5] & = & \Show\Insert\Lessthan3[1,2,4,5] +\end{eqnarray*} +$Insert$ takes in an ordering as its first parameter, so we're not stuck +with one particular order. It is defined directly in terms of the +definition of lists. +\begin{eqnarray*} + Insert~o~x~xs & = & xs~(Insert'~o~x)~(Singleton~x) \\ + Insert'~o~x~y~ys & = & o~x~y \\ + & & \quad (Cons~x~(Cons~y~ys)) \\ + & & \quad (Cons~y~(Insert~o~x~ys)) +\end{eqnarray*} +We can then define the function all this has been leading up to, +$Insertsort$ which takes an ordering and a list, and insert-sorts the +list according to the ordering. For example, +\begin{eqnarray*} + Insertsort~Lessthan~[2,3,1,2] & = & \Show\Insertsort\Lessthan[2,3,1,2] +\end{eqnarray*} +We can implement this as a fold: +\begin{eqnarray*} + Insertsort~o & = & Foldr~(Insert~o)~Nil +\end{eqnarray*} +And so we've got sorted lists. +\begin{TeXcode} +\def\Insert#1#2#3% + {#3{\Insert@{#1}{#2}}{\Singleton{#2}}} +\def\Insert@#1#2#3#4% + {#1{#2}{#3}% + {\Cons{#2}{\Cons{#3}{#4}}}% + {\Cons{#3}{\Insert{#1}{#2}{#4}}}} +\def\Insertsort#1{\Foldr{\Insert{#1}}\Nil} +\end{TeXcode} +Interestingly, as we have implemented unbounded lists in \TeX's mouth, +this means we can implement a Turing Machine. So, if you believe +the Church-Turing thesis, \TeX's mouth is as powerful as any +computer anywhere. Isn't that good to know? + +\section{Sorting reference lists} +\label{thissection} + +So, these are the macros I've got to play with --- how do we apply them to +sorting lists of references? Well, I'm using \LaTeX, which keeps the +current reference in a macro called \verb|\@currentlabel|, which +is~\ref{thissection} at the moment, as this is Section~\ref{thissection}. +So I just need to store the value of \verb|\@currentlabel| somehow. + +Fortunately, I'm only ever going to be making references to facts +earlier on in the document, in order to make sure I'm not proving +any results in terms of themselves. So I don't need to play around +with auxiliary files, and can just do everything in terms of +macros. + +\subsection{Number and Label} + +Each label in the document is given a unique number, in the order +the labels were put down. So the number of \verb|Fac-cows| +is \verb|\Number{Fac-cows}|, which expands out to~\Number{Fac-cows}, +the number of \verb|Fac-people| is~\Number{Fac-people}, and so on. + +Each number has an associated label with it. For example, +the first label is \verb|\Label{1}|, which is~\Label{1}, +the second label is~\Label{2} and so on. So to find the label for +\verb|Fac-cows|, we say \verb|\Label{\Number{Fac-cows}}| which expands +out to~\Label{\Number{Fac-cows}}. + +These numbers and labels are kept track of in macros. For example, +the number of \verb|Fac-cows| is kept in \cstok{Number-Fac-cows}. +Similarly, the first label is kept in \cstok{Label-1}. +As these macros have dashes in their names, they aren't likely to +be used already. + +So the \TeX\ code for \verb|\Number| and \verb|\Label| is pretty +simple. +\begin{verbatim} +\def\Number#1{\csname Number-#1\endcsname} +\def\Label#1{\csname Label-#1\endcsname} +\end{verbatim} + +\subsection{Lastnum and Forward} + +The number of the most recent label is kept in \verb|\Lastnum|. +\begin{verbatim} +\newcount\Lastnum +\end{verbatim} +To put down a label \verb|Foo|, I type \verb|\Forward{Foo}|. +\Forward{Foo} +This increments the counter +\verb|\Lastnum|, and \verb|\xdef|s \cstok{Number-Foo} +to be the value of +\verb|\Lastnum|, which is now~\the\Lastnum. So +\verb|\Number{Foo}| now expands to~\Number{Foo}. +Similarly, it \verb|\xdef|s \cstok{Label-\Number{Foo}} to be +\verb|\@currentlabel|, which is currently~\Label{\Number{Foo}}. +So \verb|\Label{\Number{Foo}}| now expands to~\Label{\Number{Foo}}. +\begin{verbatim} +\def\Forward#1% + {\global\advance\Lastnum by 1 + \csnameafter\xdef{Number-#1}% + {\the\Lastnum}% + \csnameafter\xdef{Label-\the\Lastnum}% + {\@currentlabel}} +\end{verbatim} +This uses \verb|\csnameafter\foo{bar}|, which expands out to +\verb|\foo\bar|. +\begin{verbatim} +\def\csnameafter#1#2% + {\expandafter#1\csname#2\endcsname} +\end{verbatim} + +\subsection{Listize, Unlistize and Show} + +At the moment, lists have to be built up using \verb|\Cons| and +\verb|\Nil|, which is rather annoying. Similarly, we can't actually +do anything with a list once we've built it. We'd like some way +of converting lists in the form \verb|[a,b,c]| to and from the +form $[a,b,c]$. This is done with \verb|\Listize| and \verb|\Unlistize|. +So \verb|\Listize[a,b,c]| expands to +\begin{verbatim} +\Cons{a}{\Cons{b}{\Cons{c}{\Nil}}} +\end{verbatim} +Similarly, \verb|\Unlistize| takes the list $[a,b,c]$ and expands out +to \verb|[a, b, c]|. \verb|\Unlistize| is done with a $Foldr$. +\begin{TeXcode} +\def\Unlistize#1{[#1\Unlistize@{}]} +\def\Unlistize@#1{#1\Foldr\Commaize{}} +\def\Commaize#1#2{, #1#2} +\end{TeXcode} +The macro \verb|\Listize| is just a \TeX\ hack with pattern matching. +It would have been nice to use \verb|\@ifnextchar| for this, but +that uses \verb|\futurelet|, which doesn't expand in the mouth. Oh well. +\begin{TeXcode} +\def\Listize[#1]% + {\Listize@[#1,\relax]} +\def\Listize@#1,#2]% + {\TeXif{\ifx\relax#2}% + {\Singleton{#1}}% + {\Cons{#1}{\Listize@#2]}} +\end{TeXcode} +This only works for nonempty lists --- \verb|\Listize[]| produces the +singleton list \verb|\Singleton{}|. It also uses \verb|\relax| as its +end-of-list character, so lists with \verb|\relax| in them have to +be done by hand. You can't win them all. So +\begin{verbatim} +$\Unlistize{\Listize[a,b,c]}$ +\end{verbatim} +produces +$\Unlistize{\Listize[a,b,c]}$. This is such a common construction +that I've defined a macro \verb|\Show| such that +\verb|\Show\foo[a,b,c]| expands out to +\begin{verbatim} +\Unlistize{\foo{\Listize[a,b,c]}} +\end{verbatim} +For example, the equation +\begin{eqnarray*} + Filter\,(Lessthan\,1)\,[1,2,3] + &=& \Show\Filter{\Lessthan 1}[1,2,3] +\end{eqnarray*} +was generated with +\begin{verbatim} +\begin{eqnarray*} + Filter\,(Lessthan\,1)\,[1,2,3] + &=& \Show\Filter{\Lessthan 1}[1,2,3] +\end{eqnarray*} +\end{verbatim} +Many of the examples in this article were typeset this way. +\begin{TeXcode} +\def\Show#1[#2]% + {\Unlistize{#1{\Listize[#2]}}} +\end{TeXcode} + +\subsection{By} + +Given these macros, we can now sort any list of references with $Bylist$, +defined +\begin{eqnarray*} + Bylist~xs & = & Map~Label \\ + & & \quad (Insertsort~Lessthan \\ + & & \quad\quad (Map~Number~xs)) +\end{eqnarray*} +This takes in a list of label names like \verb|Fac-yawn|, +converts it into a list of numbers with $Map~Number$, +sorts the resulting list with $Insertsort~Lessthan$, +and finally converts all the numbers into labels like +\Label{\Number{Fac-yawn}} with $Map~Label$. For example, +\begin{eqnarray*} + \start{Bylist~\Show\Map{\Compose\mbox\tt}[Fac-yawn,Fac-cows]} + & = & Map~Label~(Insertsort~Lessthan \\ + & & \quad (Map~Number~ + \Show\Map{\Compose\mbox\tt}[Fac-yawn,Fac-cows])) \\ + & = & Map~Label~(Insertsort~Lessthan~ + \Show\Map\Number[Fac-yawn,Fac-cows]) \\ + & = & Map~Label~\Show\Compose{\Insertsort\Lessthan}{\Map\Number} + [Fac-yawn,Fac-cows] \\ + & = & \Show\Bylist[Fac-yawn,Fac-cows] +\end{eqnarray*} +The \TeX\ code for this is +\begin{verbatim} +\def\Bylist#1% + {\Map\Label + {\Insertsort\Lessthan + {\Map\Number{#1}}}} +\end{verbatim} +So we can now stick all this together, and define the macro \verb|\By| +that prints out lists of references. It is +\begin{verbatim} +\def\By{\Show\Bylist} +\end{verbatim} +So \verb|\By[Fac-yawn,Fac-cows]| is~\By[Fac-yawn,Fac-cows]. +Which is quite nice. + +\section{Other applications} +\label{outputroutines} + +Is all this worth it? Well, I've managed to get my lists of facts in +order, but that's not the world's most astonishing application. +There are other things that these lists are useful for, though. + +For example, Damian Cugley has a macro package under development for +laying out magazines. {\sc Mag}\TeX's output routine needs to be quite +smart, as magazines often have gaps where illustrations or photographs +are going to live. In general, each block of text needs to be output +in a different fashion from every other block of text. +This will be handled by keeping an infinite list of output +routines. Each time a box is cut off the scroll to be output, +the head of the list is chopped off and is used as the output routine +for that box. That way, quite complex page shapes can be built up. + +Mainly, though, these macros were written just as a challenge. +I learned quite a lot about \TeX\ and needed some \TeX niques I'd +never seen before. It was also quite pleasing to see that \TeX\ code +can be formally verified, albeit in a rather noddy way. Without +some sort of abstract view of lists, these \TeX\ macros could +not have been written. + +\section{Acknowledgements} + +Thanks to Jeremy Gibbons for letting me bounce ideas off him +and spotting the duff ones, +to Damian Cugley for saying ``Do you really think \TeX\ is meant +to do this?'', and to the Problem Solving Club for hearing me out. +This work was sponsored by the Science and Engineering +Research Council and Hewlett Packard. + +\makesignature + +\end{document} + diff --git a/Master/texmf-dist/doc/latex/skak/refman.tex b/Master/texmf-dist/doc/latex/skak/refman.tex new file mode 100644 index 00000000000..3b093254fff --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/refman.tex @@ -0,0 +1,309 @@ +\documentclass[10pt,a4paper,twocolumn,landscape]{article} + +%\usepackage{a4wide} +\usepackage[dvips]{geometry} + +\usepackage{titlesec} +\titleformat{\section} + {\sffamily\large\bfseries}{}{0em}{} +\titleformat{\subsection} + {\sffamily\normalsize\bfseries}{}{0em}{} + +\titlespacing*{\section}{0pt}{1.5ex plus 0.5ex minus .2ex}{1ex plus + .2ex} +% \titlespacing*{\subsection}{0pt}{2.5ex plus 0.75ex minus .2ex}{1ex +% plus .2ex} + +\usepackage{fancyhdr} +\pagestyle{fancy} +\fancyhead{} +\chead{\textbf{\texttt{skak} version 1.2 \textsf{Reference Manual}}} + + +\usepackage[ps]{skak} + +\newcommand{\Cmd}[1]{\textsf{\textbf{\textbackslash#1}}} +\newcommand{\Arg}[1]{\textsf{\textsl{#1}}} + +\newcommand{\Option}[2]{\textsf{\textbf{#1}}\ #2\smallskip} + +\newcommand{\ArgInDescription}[1]{\Arg{\{#1\}}} + +\newcommand{\command}[3]{\Cmd{#1}\Apply{\ArgInDescription}{\Listize[#2]}\newline#3\smallskip} + +\newcommand{\simpleCommand}[2]{\Cmd{#1}\newline#2\smallskip} + +\setlength{\parindent}{0pt} + +\newcommand{\myheading}[1]{{\large{\textsf{\textbf{#1}}}}\bigskip} + +\begin{document} +%\tracingmacros=0 + +%\twocolumn + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Updating the board} +%\myheading{Updating the board} + +% These commands are used to update the position on the +% board. \Cmd{mainline} is the heart of the \texttt{skak} package. + + + +\simpleCommand{newgame} +{Initialises the board to the opening position.} + +\command{mainline}{SAN moves} +{Updates the board with the \Arg{SAN moves} and +typesets \Arg{SAN moves} according to the current \Cmd{mainlinestyle}.} + +\command{hidemoves}{SAN moves} +{Updates the board with the \Arg{SAN moves} but does + \emph{not} typeset the moves --- this is useful for commenting a + game where you want to focus on a certain position after + some moves have already been made.} + +\def\tmpCmd#1{\Arg{\textless row#1\textgreater/}} +\command{fenboard}{FEN position} +{Initialises the board to the position described with \Arg{FEN + position}. The format of a FEN position is:\newline + \Arg{\textless board rows\textgreater} \Arg{w\textbar + b} \Arg{\textless castling options\textgreater} \Arg{\textless en + passant square\textgreater}\newline \Arg{\textless 50 moves + counter\textgreater} \Arg{\textless move number\textgreater}\newline +The FEN for the opening position is\newline +\Arg{rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR}\newline +\Arg{w KQkq - 0 1}\newline +Note: the 50 moves counter is not used by the \texttt{skak} game +engine, but it is updated to stay in sync with external programs.} + +% \simpleCommand{boardasfen} +% {Returns the current position in the FEN notation.} + +%\newpage + + + +%\newpage +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Describing moves} +\bigskip + + +% Apart from showing the moves that update the board it is also +% possible to describe moves in the running text. + +\command{variation}{SAN moves} +{This will typeset \Arg{SAN moves} using the current \Cmd{variationstyle}.} + +\command{wmove}{SAN move} +{Typesets \Arg{SAN move} using the current \Cmd{variationstyle}. +Example: \texttt{\textbackslash wmove\{Nf3\}} gives \wmove{Nf3}.} + +\command{bmove}{SAN move} +{Typesets \Arg{SAN move} using the current \Cmd{variationstyle} but + with \ldots (or something similar according to the style) in front + of the move --- can be used to describe a single black move. Example: + \texttt{\textbackslash bmove\{Nxd4\}} gives \bmove{Nxd4}} + +\command{movecomment}{Chess moves} +{Typesets the \Arg{Chess moves} using the current \Cmd{variationstyle}, +but doesn't check for move numbers like \Cmd{variation} does.} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Showing the board} + + + +\simpleCommand{showboard} +{Shows the current position from whites perspective.} + +\simpleCommand{showinverseboard} +{Shows the current position from blacks perspective.} + + + +\section{Style selection} + +\simpleCommand{styleA} +{Chooses the \Arg{styleA} for typesetting of moves.} + +\simpleCommand{styleB} +{Chooses the \Arg{styleB} for typesetting of moves. This is the + default style.} + +\simpleCommand{styleC} +{Chooses the \Arg{styleC} for typesetting of moves.} + + +%\newpage + + +\section{Size of the board} + + + +\simpleCommand{normalboard} +{The default size of the board typeset by the \Cmd{showboard} + commands.} + +\newcommand{\boardsize}[1]{ +\simpleCommand{#1board} +{The \Cmd{showboard} commands will be typeset in a #1 font.}} + +\boardsize{tiny} + +\boardsize{small} + +\boardsize{large} + +%\newpage +\section{Notation and mover} + +\simpleCommand{notationOn} +{The \Cmd{showboard} commands show rank and file names. This is the + default.} + +\simpleCommand{notationOff} +{The \Cmd{showboard} commands show only the board.} + +\simpleCommand{showmoverOn} +{The \Cmd{showboard} commands indicate --- with a small box --- which + player has to move.} + +\simpleCommand{showmoverOff} +{The dual of \Cmd{showmoverOn}.} + + + +\section{Selective showing of pieces} + +\simpleCommand{showall} +{Makes the \Cmd{showboard} commands show all pieces.} + +\simpleCommand{showonlywhite} +{The \Cmd{showboard} commands will only show the white pieces.} + +\simpleCommand{showonlyblack} +{The \Cmd{showboard} commands will only show the black pieces.} + +\simpleCommand{showonlypawns} +{The \Cmd{showboard} commands will only show the pawns.} + +\command{showonly}{piece names} +{The argument \Arg{piece names} is a comma separated list of names of + pieces to be shown using the \Cmd{showboard} commands. White pieces + are named \Arg{K,Q,R,B,N,P} and black's \Arg{k,q,r,b,n,p}.} + +%\newpage +\section{Move arrows} + +\command{printarrow}{from,to} +{Draws an arrow on the last typeset + board from the square \Arg{from} to the square \Arg{to}.} + +\Cmd{highlight}\Arg{[ms]}\Arg{\{square list\}}\newline +The comma separated \Arg{square list} will by default be highlighted using a + thick frame on the last + typeset board. The optional marker symbol +\Arg{ms} can be one of X, x, O and o in + which case a cross or a circle is used to highlight the square. + +\command{printknightmove}{from,to} +{Draws a bent arrow from the square \Arg{from} to the square \Arg{to}.} + +%\newpage +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Customizations} + +\command{newskaklanguage}{language,piecenames} +{Defines a new \Arg{language} for the input of SAN + moves. \Arg{piecenames} are the uppercase letters used for the + pieces in the order King, Queen, Rook, Bishop, Knight, + Pawn. Example: +\mbox{\texttt{\textbackslash newskaklanguage\{danish\}\{KDTLSB\}}} +defines \Arg{danish} as a new input language.} + +\Cmd{skaklanguage}\Arg{[language]}\newline +Chooses \Arg{language} as new input language --- defaults to \Arg{english}. + +\smallskip + +\simpleCommand{mainlinestyle} +{Activates the typesetting style for the mainline --- this command can + be redefined if special requirements for the typesetting exists.} + +\simpleCommand{variationstyle} +{Similar to \Cmd{mainlinestyle} just for the typesetting of variations.} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Game storage} + + +\command{savegame}{file name} +{Writes the FEN string for the current position on the board to the + file \texttt{\textless file name\textgreater.fen}} + +\command{loadgame}{file name} {Load the position stored in the file + \texttt{\textless file name\textgreater.fen}} + +\command{storegame}{name} +{Stores the current game position using \Arg{name} as reference.} + +\command{restoregame}{name} +{Restores the game previously saved using \Cmd{storegame}.} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Package options} + +\Option{ps}{Includes the \texttt{ps-tricks} package in order to make + ornaments on the board. Required to make the following commands + work: \Cmd{showmoverOn}, \Cmd{printarrow}, \Cmd{highlight}, + \Cmd{printknightmove}.} + +\Option{psoff}{Does \emph{not} include the \texttt{ps-tricks} package.} + +\Option{mover}{Issues the \Cmd{showmoveOn} command.} + +\Option{moveroff}{Issues the \Cmd{showmoveOn} command.} + +\Option{notation}{Issues the \Cmd{notationOn} command.} + +\Option{english}{Makes english the preferred input language --- the + only defined language at the moment.} + +\Option{styleA}{Chooses \Cmd{styleA} style for the typesetting of + moves.} + +\Option{styleB}{Chooses \Cmd{styleB} style for the typesetting of + moves.} + +\Option{styleC}{Chooses \Cmd{styleC} style for the typesetting of + moves.} + +\newcommand{\sizeoption}[1]{\Option{#1}{The board is shown using the + #1 size font.}} + +\sizeoption{tiny} + +\sizeoption{small} + +\sizeoption{normal} + +\sizeoption{large} + +\bigskip + +The default options are \textsf{\textbf{notation, normal, psoff, + english, moveroff, styleB}}. + +\end{document} + + + + + + diff --git a/Master/texmf-dist/doc/latex/skak/skakdoc.tex b/Master/texmf-dist/doc/latex/skak/skakdoc.tex new file mode 100644 index 00000000000..69c11c8c29d --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/skakdoc.tex @@ -0,0 +1,417 @@ +\documentclass[11pt,twocolumn]{article} + +\usepackage{lambda,ifthen,calc} +\usepackage{tabularx} +\usepackage[ps,mover]{skak} + +\newcommand{\package}[1]{\textsf{#1}} +\newcommand{\pgn}{PGN\ } +\newcommand{\san}{SAN\ } +\newcommand{\fen}{FEN\ } +\newcommand{\xboard}{xboard} +\newcommand{\metafont}{\textsc{Metafont}\ } +\newcommand{\filename}[1]{\texttt{#1}} +%\usepackage[a5paper]{anysize} +%\tracingmacros=1 + +\newcommand{\Guido}{Guido Governatori\ } +\newcommand{\Harri}{Harri Haanpaa\ } +\newcommand{\Ingo}{Ingo Sander\ } +\newcommand{\Dirk}{Dirk B\"achle\ } +\newcommand{\Ulrike}{Ulrike Fischer\ } +\newcommand{\Andreas}{Andreas Wilm\ } + +\title{Typesetting Chess in \LaTeX with the \package{skak} Package\\ +Version 1.3} +\author{Torben Hoffmann\\ e-mail: \texttt{Torben.Hoffmann@motorola.com}} +\begin{document} +\maketitle + +\begin{abstract} + This user guide shows how to use an enhancement to the existing + package for typesetting chess in \LaTeX (\package{skak}). The + primary improvement over the old package is that it has become + easier to typeset chess games with this new package. +\end{abstract} + +\newpage +\tableofcontents +\newpage + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Change History} +\label{sec:change-history} + + +\subsection*{Version 1.3} +\label{sec:version-1.3} + +\begin{itemize} +\item \Dirk has reworked the typesetting of chess moves: + \begin{itemize} + \item A new capture symbol has been introduced to make the spacing around + it better. + \item The figurine symbols have been improved so that the spacing around + them are more uniform --- it looks really good now, at least to my eyes. + \item A proposal for what syntax the \package{skak} package should handle in + the future has been included in the distribution. + \item The Informator symbols ``novelty'', ``comment'' and ``various'' needed + another pair of curly braces in order to work right within the + ``mainline'' and ``variation'' environments. + \item The check for trailing spaces in the macro ``typeset@cmoves'' had to + be removed because it led to problems at the end of a ``mainline'' or + ``variation'' environment when an additional Informator symbol was + involved. + \end{itemize} +\item A reference to the \textsf{pgn2ltx} tool created by \Dirk has been added + to the document. +\item A reference to an URL decribing the \pgn standard has been added. +\end{itemize} + + +\subsection*{Version 1.2} +\label{sec:version-1.2} + +\begin{itemize} +\item \Dirk has --- once again --- done a great job: + \begin{itemize} + \item the informator symbols have been improved and now scale as + they should (I have in the same go done some \metafont clean-up + associated with the symbols). + \item he has also discovered that the selection of other fonts for + the typesetting of moves can be done by redefining the + \verb|\skakfamily| command! + \item added the \verb|\movecomment| for flexible typesetting of + comments --- see the Reference Manual for details. + \item The PostScript file are now 10 times smaller (for large files) + and a comprehensive test of the PostScript ornaments has been + created. + \end{itemize} +\item All dead code has been removed from \texttt{skak.sty}. +\end{itemize} + + +\subsection*{Version 1.1} +\label{sec:version-1.1} + +\begin{itemize} +\item \Dirk's enhancements have been incorporated: + \begin{itemize} + \item extension of the \verb|\highlight| command; it now accepts X, + x, O and o as optional arguments and produces a cross and a + circle on the square, respectively, instead of a frame around the + square. + \item unwanted generation of spaces removed. + \item a set of Informator symbols were added to the fonts and made + available through commands documented in the + \texttt{informator.ps} file. + \end{itemize} +\item Two fixes by \Ulrike have been incorporated: + \begin{itemize} + \item a bug in \verb|\ParseCoordinates|. + \item a problem in the fonts regarding size. + \end{itemize} +\item \Ulrike reported a problem with opening spaces causing the input + to be ignored --- this has been fixed and \filename{test/test2.tex} + verifies this. +\end{itemize} + + + +\subsection*{Version 1.0} +\label{sec:version-1.0} + +The major novelty in this release is that the documentation has been +updated and a reference manual has been created. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Terms of Usage} +\label{sec:terms-usage} + +This package is distributed under the terms described in the Latex +Project Public Licence, i.e., + +\begin{quote} + This software is copyright but you are granted a license which gives + you, the ``user'' of the software, legal permission to copy, + distribute, and/or modify the software. However, if you modify the + software and then distribute it (even just locally) you must change + the name of the software to avoid confusion. +\end{quote} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Acknowledgements} +\label{sec:acknowledgements} + +I would like to thank the creator of the \package{lambda} package, +Alan Jeffrey, for making a splendid package that made this package +possible. + +For discussions and alpha-testing I send my thanks to \Guido --- some +of his ideas have already been implemented; the rest? Time will show. + +Thanks to \Harri for finding a nasty bug in the castling routine. + +A big thank goes to \Dirk for adding the Informator symbols to the +fonts and for removing a couple of nasty bugs as well as improving +some of the commands. + +I thank \Ulrike for spotting as well as fixing a big problem with the +parsing of moves and for her hints to improving the fonts. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{The Old \package{chess} Package Versus the New \package{skak} + Package} +\label{sec:old-vs-new} + +The main reason for considering an improvement of the \package{chess} +package that Piet Tutelaers made back in 1991 is the cumbersome user +interface the package has when one wants to write about a chess game +and display a diagram every now and then. Typesetting the two opening +moves where white and black move their kingside knights is done as +follows in the \package{chess} package: + +\begin{verbatim} +\move g1f3 g8f6 +\end{verbatim} + +The package then produces a nice typesetting of these moves in figurine +notation, but it is hard to keep track of what is going on because one usually +uses the \san (Short Algebraic Notation, employed in the \pgn standard for +typing the moves --- see \texttt{http://pgn.freeservers.com/standard.txt} for +details) to write down the moves of a chess game. The \san version of the two +moves above is: \verb|1. Nf3 Nf6|, which is much clearer to most chess +players. In the \package{skak} package the author of a chess article is +allowed to use the \san notation as input to the command that updates the +chess board. In addition to making it easier for the author to write about +chess using a familiar notation it also provides an easy way to include moves +generated by a chess program such as \xboard\ in the document---most other +chess programs can also output a \pgn version of a chess game and from that +you can extract the \san recording of the moves. + +The \package{skak} package can also input chess board positions given +in the \fen notation (also used in the \pgn standard), which is also quite +standard in the domain of chess programs. + +Apart from a better user interface the \package{skak} chess font +contains three small modifications of the font created by Piet +Tutelaers: the knight now looks a bit more ``youthful'', the contour +of the queen has been smoothened and all the chess pieces have been +shrunk such that they do not fill as much of a square as before. I +find this font nicer to look at, but your milage may vary. + + + + +\section{How to use the \package{skak} Package} +\label{sec:how-use-skak-package} + +Writing about a chess game can be done straightforward: + +\begin{verbatim} +\newgame + +\mainline{1. e4 e5 2. Nf3 Bc5} +\end{verbatim} + +\newgame +\noindent +starts a new game and produces the following in your document: + +\mainline{1. e4 e5 2. Nf3 Bc5} + +So far, so good. If you want to show the current position you just +type \verb|\[\showboard\]| in your document to get: + +\[\showboard\] + +\noindent +(the use of math \verb|\[...\]| is just to make sure the board is centered.) + +This is the basic functionality of the \package{skak} package, but it +offers many different ways in which one can talk about chess +games. I think that a good way to show how the \package{skak} package +can be used is to typeset the Fischer--Tal game from the old +\package{chess} package. The result is in the file named +\filename{tuggame.ps}. + +Further information about all the bells and whistles the +\package{skak} package provides can be found in the \emph{Reference + Manual} where all commands of relevance are described. + + +\subsection{Handling of Variations} +\label{sec:handling-variations} + + +The \package{skak} package does \emph{not} support +\pgn variations such as +\begin{verbatim} +\mainline{12. Bb4 (12. Ng5 h6) 12... Ra8} +%gives an error +\end{verbatim} + +You have to type this as +\begin{verbatim} +\mainline{12. Bb4} +\variation{12. Ng5 h6} +\mainline{12...Ra8} +\end{verbatim} + +I do not have the nerves to update the parsing algorithm to cope with +this so the best thing to do would be to craft a tool for translating +\pgn to \TeX (see \ref{sec:transl-pgn-files}). + + +\subsection{Changing the Font} +\label{sec:changing-font} + +(New in Version 1.2) + +\Dirk has discovred that you can change the font used for typesetting +of moves if you redefine the \verb|\skakfamily| font. + +I do not --- however --- know how to handle different chess fonts, so +if someone could work this out I'll include that in a future version. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Installing the \package{skak} Package} +\label{sec:install} + +I could not get the makefile to do the job, so if someone could help +me out on this I would be very glad indeed. + +Basically all you have to do is to follow the guidelines in the +makefile. First you create all the required directories (stated in the +\texttt{install} section of the makefile) and then you run the +\texttt{make install} command. Remember to run \texttt{texhash} after +you have updated your texmf tree. + +Sorry that it is not working $100\%$--- I just do not have the time for +it right now. + +If you cannot get the things working just put the files where \TeX and +the other tools can find them and you will be just fine. + + +\subsection{Using the \package{lambda} Package} +\label{sec:using-lambda} + +The \package{skak} package uses the \package{lambda} package to do +some of the hard processing necessary to allow the \pgn notation as +input --- since it is not standard in \LaTeX distributions it is +included in the distribution of the \package{skak} package. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Future Additions/Wish-list} +\label{sec:future-additions} + + +\subsection{Choosing Language for \texttt{mainline}}\label{sec:choos-lang-mainline} + +(Proposal date: mid 2002.) + +It would be nice if one could choose the language for the +\verb|mainline|, \verb|variation| and \verb|\hidemoves| for each invocation +as it allows for easier inclusion of analysis from chess programs when +using a non-english language. + + +\subsection{Algebraic Notation used for Typesetting} +\label{sec:algebraic-notation-in-typesetting} + +(Proposal date: mid 2001.) + +\Ingo has suggested that the output of the typesetting should be the +old algebraic notation where the from and to squares always are +given. This requires a modification to the game engine: after each +move has been made you should store the algebraic notation of the move +since you have the to and from squares calculated at that +moment. Changing the game engine is a bit hairy --- even for me --- so I'll +postpone this. + + +\subsection{Fonts} +\label{sec:ps-font} + +(Proposal date: dec-2002.) + +\Ulrike has suggested the creation PostScript version of the \metafont +font. + +I do not know how to do this, but perhaps someone can help me? + +Furthermore, \Ulrike would like to see a more transparent +fonthandling, so that it becomes easy to change to another chess-font. +(Version 1.2 news: see Section~\ref{sec:changing-font}.) + + +\subsection{Optimisation of the Implementation} +\label{sec:optim-impl} + +(Proposal date: 2-Jan-2003.) + +I would like to improve some areas of the implementation since they +are unnecessary slow and/or complicated, e.g., \verb|\IsPieceName| +could easily be implemented as a case statement instead of a list +look-up. I have a strong feeling that this would be a lot faster than +the current implementation which has a very functional programming +flavour --- this was very helpful during the development, but it has a +tendency to be a bit inefficient. + +Another great improvement would be to let the commands +\verb|\Mainline| and \verb|\typeset@A| use the same parsing algorithm +--- then one could implement the long algebraic notation as suggested +by \Ingo by letting the action taken on a move be both updating of the +board \emph{and} typesetting of the move! + +\subsection{Test Suite} +\label{sec:test-suite} + +(Proposal date: 03-Jan-2003.) + +It would be a very good idea to create a test suite created using +normal testing techniques. +Areas of test should include: +\begin{itemize} +\item resolving ambiguous moves, i.e., ensuring that moves like + \wmove{Rad1} moves the right rook. +\item all legal \san moves are accepted. +\end{itemize} + + + +\subsection{Translating \pgn Files} +\label{sec:transl-pgn-files} + +(Proposal date: 03-Jan-2003.) + +It would be very nice if one had a command line tool that could +translate \pgn files to a \TeX file. + +27-Sep-2003: Take a look at \texttt{http://pgn2ltx.sourceforge.net} for a nice +helper tool. + + +\subsection{Typesetting \textsl{e.p.} after en passant moves} +\label{sec:typeset-en-passant} + +\Andreas asked how one should input en passant moves, especially the addition +of \textsl{e.p.} after the capture. + +This is not part of the \san notation as described in the \pgn standard and it +requires that the improvement described in Section \ref{sec:optim-impl} is in +place before it is possible to add the possibility to add the +\textsl{e.p.}. It has to be this way because I do not want to support more +than what is described by the \pgn standard. + + +\end{document} + + + + + diff --git a/Master/texmf-dist/doc/latex/skak/syntax.tex b/Master/texmf-dist/doc/latex/skak/syntax.tex new file mode 100644 index 00000000000..ecc48f79310 --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/syntax.tex @@ -0,0 +1,321 @@ +\documentclass[a4paper]{article} + +\usepackage{skak} + +\def\package#1{``\textsf{#1}''} +\def\command#1{``\texttt{\symbol{92}#1}''} +\def\commandwarg#1#2{\texttt{\symbol{92}#1}\{\textit{#2}\}} +\def\base#1{$_{\scriptscriptstyle #1}$} +\def\abbrev#1{\textsf{#1}} +\def\bnf#1{\textit{#1}} +\def\bnfterm#1{\textbf{#1}} +\def\bnfprod{$\rightarrow$} +\def\bnfempty{$\epsilon$} +\def\bnfor{$|$} +\def\bnfjoin{$\bowtie$} + +\setlength{\parindent}{0pt} + +\title{The Syntax of Chess Moves in the \LaTeX{} Package \package{skak} (Draft)} +\author{Dirk B\"achle} + +\begin{document} + +\maketitle + +\begin{abstract} +This short document contains some thoughts and ideas about the ``to be supported'' +syntax of chess moves, including SAN (Short Algebraic Notation) as well as LAN +(Long Algebraic Notation). + +The main purpose of this draft is to specify a concrete set of allowed chess moves. +In the next step, extensive test routines for this syntax should be generated +that can be used to verify the final implementation\ldots +\end{abstract} + +\section*{Stage 1: Parsing \command{mainline}/\command{variation}} + +The commands \command{mainline} and \command{variation} should accept +a nonemtpy list of space separated ``move tokens'' (\abbrev{MT}): + +\medskip +\hfil\commandwarg{mainline}{MT\_list}\hfil or \hfil\commandwarg{variation}{MT\_list}\hfil + +where + +\begin{center} +\begin{minipage}{3cm} +\begin{tabbing} +\bnf{MT\_list} \bnfprod\={} \bnf{MT} \bnfterm{space} \bnf{MT\_list}\\ + \>\bnfor{} \bnf{MT} +\end{tabbing} +\end{minipage} +\end{center} + +using BNF (Backus-Naur Form) notation with `\bnfterm{space}' as the +terminal symbol for the character '\ ' (ASCII code +32\base{10}). + +\section*{Stage 2: Splitting off move numbers} + +Each \abbrev{MT} may be either a chess move (\abbrev{CM}), a move number (\abbrev{MN}) +or a token like ``\texttt{2.Kg1}'' that combines both: + +\begin{center} +\begin{minipage}{3cm} +\begin{tabbing} +\bnf{MT} \bnfprod\={} \bnf{MN} \bnf{CM}\\ + \>\bnfor{} \bnf{CM}\\ + \>\bnfor{} \bnf{MN} +\end{tabbing} +\end{minipage} +\end{center} + +The only task of this stage is to separate ``combined tokens'' (first rule in the +production above) and, therefore, supply the next stage 3 with a steady stream +of single move tokens (\abbrev{M}). + +\begin{quote} +Remark: This ``separation'' probably has to be done by inspecting the whole +token character for character. Thus, it appears to be efficient to already +collect information about the move number \abbrev{MN} (White/Black to move, +getting the number itself, suppressing leading zeros) in this early stage\ldots +\end{quote} + +No semantic checking is done here, i.e.~this stage doesn't +detect errors like \mbox{``\texttt{2.~Kg1 3.~Bf4}''}. + +\section*{Stage 3: Parsing single move tokens} + +At this point, we can be sure to get either a chess move \abbrev{CM} +or a move number \abbrev{MN}: + +\begin{center} +\begin{minipage}{3cm} +\begin{tabbing} +\bnf{M} \bnfprod\={} \bnf{CM}\\ + \>\bnfor{} \bnf{MN} +\end{tabbing} +\end{minipage} +\end{center} + +Both can be distinguished well by inspecting the first character of the token, since +only move numbers \abbrev{MN} may start with a digit (\abbrev{D}). + +This stage would be the right place to check for the correct order +of chess moves and move numbers, i.e.~if a \abbrev{MN} is encountered +the right side (White or Black) should be to move. + +\section*{Parsing move numbers} + +Move numbers \abbrev{MN} consist of an integer value (\abbrev{N}), immediately +followed by one or three dots as terminal symbols, signalling whether it's +Whites or Blacks move. + +\begin{center} +\begin{minipage}{3cm} +\begin{tabbing} +\bnf{MN} \bnfprod\={} \bnf{N} \bnfterm{...}\\ + \>\bnfor{} \bnf{N} \bnfterm{.} +\end{tabbing} +\end{minipage} +\end{center} + +An integer value \abbrev{N} is a nonempty list of single digits +(\abbrev{D})\ldots + +\begin{center} +\begin{minipage}{3cm} +\begin{tabbing} +\bnf{N} \bnfprod\={} \bnf{D} \bnf{N}\\ + \>\bnfor{} \bnf{D} +\end{tabbing} +\end{minipage} +\end{center} + +\ldots where each digit \abbrev{D} should be contained in the set of terminal +symbols 0--9. + +\begin{center} +\begin{minipage}{5cm} +\begin{tabbing} +\bnf{D} \bnfprod\={} \bnfterm{0}\bnfor\bnfterm{1}\bnfor\bnfterm{2}% +\bnfor\bnfterm{3}\bnfor\bnfterm{4}\bnfor\bnfterm{5}\bnfor\bnfterm{6}% +\bnfor\bnfterm{7}\bnfor\bnfterm{8}\bnfor\bnfterm{9} +\end{tabbing} +\end{minipage} +\end{center} + +Here, the move number can be checked against the internal move counter +if necessary. + +\section*{Parsing chess moves} + +A chess move \abbrev{CM} starts with the ``move specification'' (\abbrev{MS}), +giving information about the piece that is to move and the source and +destination squares. Additionally, an arbitrary number of character tokens may follow +as a move comment (\abbrev{MC}). So, after enough ``hints'' for executing the move +are collected, i.e.~\abbrev{MS} was ``matched'', the rest of the token is regarded +as comment \abbrev{MC} and is output unchanged. + +\begin{center} +\begin{minipage}{3cm} +\begin{tabbing} +\bnf{CM} \bnfprod\={} \bnf{MS} \bnf{MC}\\ + \>\bnfor{} \bnf{MS} +\end{tabbing} +\end{minipage} +\end{center} + +Before defining the move specification \abbrev{MS} itself a few helping nonterminal +symbols are introduced. Please, remember that bold characters within +the ``rules'' denote terminal symbols\ldots + +\begin{enumerate} +\item A ``piece'' character (\abbrev{P}) + +\begin{center} +\begin{minipage}{3cm} +\begin{tabbing} +\bnf{P} \bnfprod\={} \bnfterm{K}\bnfor\bnfterm{Q}\bnfor\bnfterm{B}% +\bnfor\bnfterm{N}\bnfor\bnfterm{R} +\end{tabbing} +\end{minipage} +\end{center} + +Remark: This definition uses the english letters for the single pieces. The +real implementation should be independent of the used language. + +\item A ``file'' character (\abbrev{f}) + +\begin{center} +\begin{minipage}{5cm} +\begin{tabbing} +\bnf{f} \bnfprod\={} \bnfterm{a}\bnfor\bnfterm{b}\bnfor\bnfterm{c}% +\bnfor\bnfterm{d}\bnfor\bnfterm{e}\bnfor\bnfterm{f}\bnfor\bnfterm{g}% +\bnfor\bnfterm{h} +\end{tabbing} +\end{minipage} +\end{center} + +\item A ``rank'' character (\abbrev{r}) + +\begin{center} +\begin{minipage}{3cm} +\begin{tabbing} +\bnf{r} \bnfprod\={} \bnfterm{1}\bnfor\bnfterm{2}\bnfor\bnfterm{3}% +\bnfor\bnfterm{4}\bnfor\bnfterm{5}\bnfor\bnfterm{6}\bnfor\bnfterm{7}% +\bnfor\bnfterm{8} +\end{tabbing} +\end{minipage} +\end{center} + +\item A ``capture'' character (\bnfjoin) + +\begin{center} +\begin{minipage}{3cm} +\begin{tabbing} +\bnfjoin{} \bnfprod\={} \bnfterm{-}\\ + \>\bnfor{} \bnfterm{x}\\ + \>\bnfor{} \bnfempty +\end{tabbing} +\end{minipage} +\end{center} + +where '\bnfempty' denotes the ``empty symbol''. + +\end{enumerate} + + +Move specifications (\abbrev{MS}) can be subdivided into the following groups: + +\begin{itemize} +\item Starting with a ``piece'' character + +\begin{itemize} +\item With source square +\begin{center} +\begin{minipage}{3cm} +\begin{tabbing} +\bnf{MS} \bnfprod\={} \bnf{P} \bnf{f} \bnf{r} \bnfjoin{} \bnf{f} \bnf{r}\\ + \>\bnfor{} \bnf{P} \bnf{f} \bnfjoin{} \bnf{f} \bnf{r}\\ + \>\bnfor{} \bnf{P} \bnf{r} \bnfjoin{} \bnf{f} \bnf{r} +\end{tabbing} +\end{minipage} +\end{center} + +Examples: ``\texttt{Qf3-f4}'', ``\texttt{Ree6}'', ``\texttt{N1xc3}'' +\item Only a destination square present + +\begin{center} +\begin{minipage}{3cm} +\begin{tabbing} +\bnf{MS} \bnfprod\={} \bnf{P} \bnfjoin{} \bnf{f} \bnf{r} +\end{tabbing} +\end{minipage} +\end{center} + +Example: ``\texttt{Nxc4}'' +\end{itemize} + +\item Without leading ``piece'' character + +\begin{itemize} +\item With source square + +\begin{center} +\begin{minipage}{3cm} +\begin{tabbing} +\bnf{MS} \bnfprod\={} \bnf{f} \bnf{r} \bnfjoin{} \bnf{f} \bnf{r} \bnf{P}\\ + \>\bnfor{} \bnf{f} \bnfjoin{} \bnf{f} \bnf{r} \bnf{P}\\ + \>\bnfor{} \bnf{f} \bnf{r} \bnfjoin{} \bnf{f} \bnf{r}\\ + \>\bnfor{} \bnf{f} \bnfjoin{} \bnf{f} \bnf{r} +\end{tabbing} +\end{minipage} +\end{center} + +Examples: ``\texttt{f7-f8R}'', ``\texttt{dxe8B}'', ``\texttt{g2-g4}'', +``\texttt{fxe6}'' +\item Only a destination square present + +\begin{center} +\begin{minipage}{3cm} +\begin{tabbing} +\bnf{MS} \bnfprod\={} \bnf{f} \bnf{r} \bnf{P}\\ + \>\bnfor{} \bnf{f} \bnf{r} +\end{tabbing} +\end{minipage} +\end{center} + +Examples: ``\texttt{e8R}'', ``\texttt{a6}'' +\end{itemize} + + +\item Castlings + +\begin{center} +\begin{minipage}{3cm} +\begin{tabbing} +\bnf{MS} \bnfprod\={} \bnfterm{O-O-O}\\ + \>\bnfor{} \bnfterm{O-O} +\end{tabbing} +\end{minipage} +\end{center} + +Both of these terminals use the letter 'O' (ASCII code +79\base{10}) and not the digit '0' +(ASCII code 48\base{10})! +\end{itemize} + +\section*{Final remark} + +This text tries to provide only the syntax for the frontend of the new ``move +machine''. All the things that happen after the input was ``matched'' and +information was drawn out of the given ``chess moves'' to the largest extent, +i.e.~the semantic actions, are beyond the scope of this document. + +So, at the moment it is perfectly legal and syntactically correct to say +``\texttt{4. gxf8K}''\ldots + +\end{document} + diff --git a/Master/texmf-dist/doc/latex/skak/test1.tex b/Master/texmf-dist/doc/latex/skak/test1.tex new file mode 100644 index 00000000000..06749874f93 --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/test1.tex @@ -0,0 +1,43 @@ + + +\documentclass[11pt,twocolumn]{article} + +\usepackage[ps,mover]{skak} + +\title{test1\\Ensuring that no Unwanted Spaces are Created} +\author{Torben Hoffmann } + +\begin{document} + +\parindent=0pt + +\maketitle + +Ulrike Fischer had a problem with unwanted spaces which should be +solved in version 1.1. + + +\newgame +\mainline{1. d4 d5} \mainline{2. Nc3 Nc6 3. Bg5 Bd7} + +\newgame +\tracingmacros=1 +\mainline{1.d4 d5} \mainline{2. Nc3 Nc6 3. e4 e5} + + +\newgame +\mainline{1.d4 d5} \mainline{2. e3 e6 3. c4 c5} + +\newgame +\mainline{1.d4 d5} \mainline{2. e3 e6 3. c4 c5} + +\showboard + + +\end{document} + + + + + + diff --git a/Master/texmf-dist/doc/latex/skak/test2.tex b/Master/texmf-dist/doc/latex/skak/test2.tex new file mode 100644 index 00000000000..2abf45fc979 --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/test2.tex @@ -0,0 +1,41 @@ + + +\documentclass[11pt,twocolumn]{article} + +\usepackage[ps,mover]{skak} + +\title{test2\\Proper Handling of Opening Spaces in the SAN Input} +\author{Torben Hoffmann } + +\begin{document} + +\parindent=0pt + +\maketitle + +Ulrike Fischer had a problem with opening spaces in the SAN input +which should be solved in version 1.1. + + +\newgame +\mainline{1.e4 e5} + +\[\showboard\] + +\newgame +\mainline{1. e4 e5} + +\[\showboard\] + +\newgame +\mainline{ 1. e4 e5} + +\[\showboard\] + +\end{document} + + + + + + diff --git a/Master/texmf-dist/doc/latex/skak/tuggame.tex b/Master/texmf-dist/doc/latex/skak/tuggame.tex new file mode 100644 index 00000000000..cbc201726be --- /dev/null +++ b/Master/texmf-dist/doc/latex/skak/tuggame.tex @@ -0,0 +1,164 @@ +% This is a skak version of the tugame.ltx which Piet Tutelaers made +% to show how the original chess package could be used. +% I have changed it to use the skak package commands as a +% demonstration of how to use the skak package. +% Author: Torben Hoffmann +% +% Change history +% -------------- +% Version Comments +% 1.0 Initial version adapted to the skak package. + +% The original comments follows below +%=================================================================== +% +% TUGgame.ltx +% ----------- +% LaTeX source of example in TUGboat article (part of the game Fisher +% lost against Tal), input'ted by TUGboat.ltx. +% Author : Piet Tutelaers (internet: rcpt@urc.tue.nl) +% Version: 1.2 ( 8 Jun 1991) +% Reflects changes in chess.sty version 1.2 +% Version: 1.1 (30 Nov 1990) +% Improvements over version 1.0: +% - two typos corrected, thanks Hugo +%=================================================================== + + +\documentclass[11pt,twocolumn]{article} + +\usepackage[ps,mover,styleC]{skak} + +\title{Example of the LaTeX-input and output of an annotated +chess game using \texttt{skak.sty}} +\author{Torben Hoffmann} + +\begin{document} + +\parindent=0pt + +\maketitle + +\section{The Input} + +\begin{verbatim} +\fenboard{1q3kr1/3rb2p/p3Q3/8/% +1p6/8/PPP3PP/4R2K w - - 0 26} + +\begin{figure}[htbp] + \begin{center} + $$\showboard$$ + \caption{Fischer--Tal after + \protect\variation{25... Kf8!}} + \label{fig:after-25...Kf8} + \end{center} +\end{figure} + + +(See figure~\ref{fig:after-25...Kf8}.) + +\mainline{26. Qxd7} + +Not \variation{26. Rf1+ Kg7 27. Rf7+ +Kh8} +and if \variation{28. Qxd7 Rd8 29. Qg4 +Qe5} +wins. + + +\mainline{26...Qd6 27. Qb7 Rg6} +Within a handful of moves the game +has changed its complexion. Now it +is White who must fight for a draw! + +\mainline{28. c3} +Black's extra piece means less with +each pawn that's exchanged. + +\mainline{28...a5} +On \variation{28...bxc3 29. Qc8+ Bd8 +30. Qxc3}=. + + +\mainline{29. Qc8+} +On the wrong track. Right is +\variation{29. cxb4 Qxb4} (if +\variation{29... axb4 30. a3! bxa3 +31. bxa3 Qxa3} draws) +\variation{30. Qf3+ Kg7 31. Qe2} draws, +since Black can't possibly build up a +winning K-side attack and his own +king is to exposed. + +\mainline{29...Kg7 30. Qc4 Bd8 +31. cxb4 axb4} +On \variation{31... Qxb4 32. Qe2} +White should draw with best play. +$$\showboard$$ +\end{verbatim} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{The Output} + +\fenboard{1q3kr1/3rb2p/p3Q3/8/% +1p6/8/PPP3PP/4R2K w - - 0 26} + +\begin{figure}[htbp] + \begin{center} + $$\showboard$$ + \caption{Fischer--Tal after + \protect\variation{25... Kf8!}} + \label{fig:after-25...Kf8} + \end{center} +\end{figure} + + +(See figure~\ref{fig:after-25...Kf8}.) + +\mainline{26. Qxd7} + +Not \variation{26. Rf1+ Kg7 27. Rf7+ +Kh8} +and if \variation{28. Qxd7 Rd8 29. Qg4 +Qe5} +wins. + + +\mainline{26...Qd6 27. Qb7 Rg6} +Within a handful of moves the game +has changed its complexion. Now it +is White who must fight for a draw! + +\mainline{28. c3} +Black's extra piece means less with +each pawn that's exchanged. + +\mainline{28...a5} +On \variation{28...bxc3 29. Qc8+ Bd8 +30. Qxc3}=. + + +\mainline{29. Qc8+} +On the wrong track. Right is +\variation{29. cxb4 Qxb4} (if +\variation{29... axb4 30. a3! bxa3 +31. bxa3 Qxa3} draws) +\variation{30. Qf3+ Kg7 31. Qe2} draws, +since Black can't possibly build up a +winning K-side attack and his own +king is to exposed. + +\mainline{29...Kg7 30. Qc4 Bd8 +31. cxb4 axb4} +On \variation{31... Qxb4 32. Qe2} +White should draw with best play. +$$\showboard$$ + + +\end{document} + + + + + + |