1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \iffalse comment
% bridge-i.sty
% \fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%% \CharacterTable
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%% Digits \0\1\2\3\4\5\6\7\8\9
%% Exclamation \! Double quote \" Hash (number) \#
%% Dollar \$ Percent \% Ampersand \&
%% Acute accent \' Left paren \( Right paren \)
%% Asterisk \* Plus \+ Comma \,
%% Minus \- Point \. Solidus \/
%% Colon \: Semicolon \; Less than \<
%% Equals \= Greater than \> Question mark \?
%% Commercial at \@ Left bracket \[ Backslash \\
%% Right bracket \] Circumflex \^ Underscore \_
%% Grave accent \` Left brace \{ Vertical bar \|
%% Right brace \} Tilde \~}
%%
%
% Style option `bridge-i' for use with LaTeX2e (version of 94/06/01 or later).
%
% This file is based on the package 'bridge' v1.7c (94/12/20) by
% J.L. Braams. Special thanks to him for supporting our work with his
% original source code. There are some major additions and some minor
% changes to his code. We hope it's alright!
%
% If there are any bugs in the code, please send a report with an
% example to BOTH authors (we are also only mailing each other because
% of the distance!):
%
% Ren\'e Steiner (rsteiner@freenet.de) AND
% Thomas Hof (bridge@twrh.de)
%
%
%
% \section{Options and Initialisation}
%
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{bridge-i}[1995/04/16 v1.0 Typesetting bridge]
% \end{macrocode}
%
% \begin{macrocode}
\typeout{*** Package bridge-i v1.0 1995/04/16 ***}
% \end{macrocode}
%
% Default macros for signs of positions
%
% \begin{macrocode}
\def\N@{N}\def\E@{E}\def\S@{S}\def\W@{W}
\def\N@rth{North}
\def\S@uth{South}
\def\E@st{East}
\def\W@st{West}
% \end{macrocode}
%
% Declaration of options
%
% \begin{macrocode}
\DeclareOption{german}
{
\gdef\N@{N}\gdef\E@{O}\gdef\S@{S}\gdef\W@{W}
\gdef\N@rth{Nord}
\gdef\S@uth{S\"ud}
\gdef\E@st{Ost}
\gdef\W@st{West}
}
\DeclareOption{dutch}
{
\gdef\N@{N}\gdef\E@{O}\gdef\S@{Z}\gdef\W@{W}
\gdef\N@rth{Noord}
\gdef\S@uth{Zuid}
\gdef\E@st{Oost}
\gdef\W@st{West}
}
\DeclareOption{francais}
{
\gdef\N@{N}\gdef\E@{E}\gdef\S@{S}\gdef\W@{O}
\gdef\N@rth{Nord}
\gdef\S@uth{Sud}
\gdef\E@st{Est}
\gdef\W@st{Ouest}
}
% \end{macrocode}
%
%
%
% Execution of options
%
% \begin{macrocode}
\ProcessOptions
% \end{macrocode}
%
% Package loading
%
% \begin{macrocode}
\RequirePackage{latexsym}[1994/05/27 v2.1e]
\RequirePackage{relsize}[1995/03/15]
% \end{macrocode}
%
% \section{Commands Overview}
%
% Commands to be used by the user:
% \begin{verbatim}
% \bidders \bidderspair \dealer \comment
% \hand \northhand \easthand \southhand \westhand
% \north \east \south \west
% \Cl \Di \He \Sp \NT \SA
% \newgame \renewNESW \setgamesize
% \showgame \showNSgame \showEWgame \showNEgame \showNWgame
% \hanghand \hangNSgame
% \onesuit \onesuitNS \onesuitEW
% \end{verbatim}
% User environments
% \begin{verbatim}
% bidding biddingpair
% \end{verbatim}
% Commands which produce texts, or influence them
% \begin{verbatim}
% \N@ \E@ \S@ \W@ \N@rth \E@st \S@uth \W@st
% \firstbidd@r \secondbidd@r \thirdbidd@r \fourthbidd@r
% \firstn@me \secondn@me \thirdn@me \fourthn@me \alln@me
% \bidderfont \namefont \gamesize
% \end{verbatim}
% Dimensions that control the layout
% \begin{verbatim}
% \handwidth The width of a hand in a game display
% \bidwidth The width of the table with the bidding sequence
% \cardskip The distance between subsequent playing cards
% \end{verbatim}
% Internal macros
% \begin{verbatim}
% \nh@nd \eh@nd \sh@nd \wh@nd
% \hhand \vhand \h@nd \h@nd@
% \cards \suit \c@rds \c@rd
% \de@l \c@mm \@drop
% \end{verbatim}
% Extra boxes
% \begin{verbatim}
% \NESW holds the center of a game display
% \end{verbatim}
%
% \section{Suits}
%
% First we supply shorthands for the `five' colours used in the
% bridge bidding. The original commands were geared towards the Dutch
% language. Here we define the 'international' version with English
% shortcuts which are easier to use for nearly every bridge player.
%
% \begin{macrocode}
%
\newcommand\Cl%
{%
$\clubsuit$%
}
\newcommand\He%
{%
$\heartsuit$%
}
\newcommand\Di%
{%
$\diamondsuit$%
}
\newcommand\Sp%
{%
$\spadesuit$%
}
\newcommand\NT%
{%
\textsc{N\kern-0.08emT}%
}
\newcommand\SA%
{%
\textsc{S\kern-0.08emA}%
}
%
% \end{macrocode}
%
% \section{Dealer}
%
% The macros for the four directions are defined above in the
% 'declare options' part to support names according to the language
% of the document written with this package.
%
%
% Next we define commands to provide more flexibility in changing
% the position of the dealer (for each direction we provide one macro)
%
% \begin{macrocode}
%
\newcommand\dealerN%
{%
\gdef\firstbidd@r{\N@rth}%
\gdef\secondbidd@r{\E@st}%
\gdef\thirdbidd@r{\S@uth}%
\gdef\fourthbidd@r{\W@st}%
}
\newcommand\dealerE%
{%
\gdef\firstbidd@r{\E@st}%
\gdef\secondbidd@r{\S@uth}%
\gdef\thirdbidd@r{\W@st}%
\gdef\fourthbidd@r{\N@rth}%
}
\newcommand\dealerS%
{%
\gdef\firstbidd@r{\S@uth}%
\gdef\secondbidd@r{\W@st}%
\gdef\thirdbidd@r{\N@rth}%
\gdef\fourthbidd@r{\E@st}%
}
\newcommand\dealerW%
{%
\gdef\firstbidd@r{\W@st}%
\gdef\secondbidd@r{\N@rth}%
\gdef\thirdbidd@r{\E@st}%
\gdef\fourthbidd@r{\S@uth}%
}
%
% \end{macrocode}
%
% Default is: North is dealer
%
% \begin{macrocode}
\dealerN
% \end{macrocode}
%
% \section{Bidders}
%
% Now we additionally define a macro to set names for the players
% of the board we are looking at.
%
% \begin{macrocode}
%
\newcommand\bidders[4]%
{%
\gdef\firstn@me{#1}%
\gdef\secondn@me{#2}%
\gdef\thirdn@me{#3}%
\gdef\fourthn@me{#4}%
\gdef\alln@me{#1#2#3#4}%
}
%
% \end{macrocode}
%
% Default is: no names, only positions
%
% \begin{macrocode}
\bidders{}{}{}{}
% \end{macrocode}
%
% The last new command defines the names of a players pair only.
% For simplification we only set the first and the third name
% of the 'table'. E.g. it might be useful if you only want to look at
% the bidding sequence of one pair without disturbation through the
% other pair.
%
% \begin{macrocode}
%
\newcommand\bidderspair[2]%
{%
\bidders{#1}{}{#2}{}%
}
%
% \end{macrocode}
%
% \section{Hands and Game Display}
%
% Again the following commands are substitutes of the originals
% which were geared towards the Dutch language. We gave them
% international, i.e. English, names to make them easier to use.
% The purpose of these macros is to store the cards each player
% holds in private macros. In this way the same game can be shown
% again, with minor changes in two hands, without having to
% specify everything all over again.
% The user should specify the cards in the order spades, hearts
% diamonds and clubs.
% Notice that the macros in which the info is stored call an
% internal macro \verb+\h@nd+ when executed.
%
% \begin{macrocode}
%
\newcommand\northhand[4]%
{%
\gdef\nh@nd{\h@nd{t}{#1}{#2}{#3}{#4}}%
}
\newcommand\southhand[4]%
{%
\gdef\sh@nd{\h@nd{t}{#1}{#2}{#3}{#4}}%
}
\newcommand\easthand[4]%
{%
\gdef\eh@nd{\h@nd{c}{#1}{#2}{#3}{#4}}%
}
\newcommand\westhand[4]%
{%
\gdef\wh@nd{\h@nd{c}{#1}{#2}{#3}{#4}}%
}
\newcommand\north[1]%
{%
\gdef\nh@nd{\h@nd@{#1}}%
}
\newcommand\south[1]%
{%
\gdef\sh@nd{\h@nd@{#1}}%
}
\newcommand\east[1]%
{%
\gdef\eh@nd{\h@nd@{#1}}%
}
\newcommand\west[1]%
{%
\gdef\wh@nd{\h@nd@{#1}}%
}
%
% \end{macrocode}
%
% One could want to add some more information about a game. For
% instance the information about dealer and vulnerability can be
% stored by using the macro \verb+\dealer+ which will put this
% information in the top left hand side of a game display.
%
% \begin{macrocode}
%
\newcommand\dealer[1]%
{%
\gdef\de@l{#1}%
}
%
% \end{macrocode}
%
% Some more information can be stored via \verb+\comment+, it will
% show up in the top right hand of a game display. Here, e.g., you
% can specify the number of the hand or other info of special interest.
%
% \begin{macrocode}
%
\newcommand\comment[1]%
{%
\gdef\c@mm{#1}%
}
%
% \end{macrocode}
%
% The macros which store texts for later use have to be initialized.
% The user should also be able to do this to clear out all his
% previous definitions. So we define a macro \verb+\newgame+ and
% execute it immediately.
%
% \begin{macrocode}
%
\newcommand\newgame%
{%
\gdef\de@l{}%
\gdef\c@mm{}%
\gdef\nh@nd{\h@nd{t}{}{}{}{}}%
\gdef\eh@nd{\h@nd{c}{}{}{}{}}%
\gdef\sh@nd{\h@nd{t}{}{}{}{}}%
\gdef\wh@nd{\h@nd{c}{}{}{}{}}%
}
%
% \end{macrocode}
%
% Now, clear the game
%
% \begin{macrocode}
\newgame
% \end{macrocode}
%
% The following parameters control the layout of the game displays
% and bidding sequences.
%
% \begin{macrocode}
%
\newdimen\cardskip \setlength\cardskip{1.2pt}
\newlength\handwidth \setlength\handwidth{4.5pc}
\newlength\bidwidth \setlength\bidwidth{13pc}
%
\newcommand\bidderfont[1]% the font used for the positions
{%
\textsl{#1}%
}
%
\newcommand\namefont[1]% the font used for the names of the players
{%
\textrm{#1}%
}
%
% \end{macrocode}
%
% \begin{macro}{\hand}
% The following command can be used to describe one single hand
% in the midst of a paragraph, or next to a bidding sequence if
% one wants to show only the hand the reader is `holding' and the
% bidding sequence. (This can be useful in bridge problems.)
%
% \begin{macrocode}
%
\newcommand\hand[4]%
{%
\ifhmode%
\hhand{#1}{#2}{#3}{#4}%
\else%
\vhand{#1}{#2}{#3}{#4}%
\fi%
}
%
% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{\gamesize}
% A control sequence to hold the size game displays are set in.
%
% \begin{macrocode}
%
\let\gamesize\normalsize
%
% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{\setgamesize}
% A control sequence to change the above one.
%
% \begin{macrocode}
%
\newcommand\setgamesize[1]%
{%
\let\gamesize#1
\renewNESW
}
%
% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{\showgame}
% The next command formats all the information, stored via macros
% presented earlier. The arguments to \verb+\dealer+ and \verb+\comment+
% end up in a minipage, so the user can specify more than one line.
% In addition to the original version we allow one optional parameter
% for specification of the alignment of the tabular (defaults to 't').
%
% \begin{macrocode}
%
\newcommand\showgame[1][t]%
{%
\par%
{%
\gamesize%
\begin{tabular}[#1]{@{}l@{}l@{}l@{}}%
\vtop{\hsize\handwidth\@parboxrestore\de@l}%
& \nh@nd & \vtop{\hsize\handwidth\@parboxrestore\c@mm}\\
\wh@nd & \usebox{\NESW} & \eh@nd\\
& \sh@nd & \\
\end{tabular}%
\par%
}%
}
%
% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{\showNSgame}
%
% \begin{macrocode}
%
\newcommand\showNSgame[1][c]%
{%
\bgroup%
\gamesize%
%
% the following line is commented because of problems
% with \playproblemNS in kibitzer.sty
% \addtolength\handwidth{0.4\handwidth}%
%
\begin{tabular}[#1]{@{}l@{}}%
\vtop{\hsize\handwidth\@parboxrestore\c@mm}\\
\nh@nd\\
\usebox{\NESW}\\
\sh@nd\\
\end{tabular}%
\egroup%
}
%
% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{\showEWgame}
%
% \begin{macrocode}
%
\newcommand\showEWgame[1][t]%
{%
\bgroup%
\gamesize%
\begin{tabular}[#1]{@{}l@{}l@{}l@{}}%
\vtop{\hsize\handwidth\@parboxrestore\de@l}%
& & \vtop{\hsize\handwidth\@parboxrestore\c@mm}\\
\wh@nd & \usebox{\NESW} & \eh@nd\\
\end{tabular}%
\egroup%
}
%
% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{\showNEgame}
%
% \begin{macrocode}
%
\newcommand\showNEgame[1][c]%
{%
\bgroup%
\gamesize%
\begin{tabular}[#1]{@{}l@{}l@{}}%
\nh@nd & \vtop{\hsize\handwidth\@parboxrestore\c@mm}\\
\usebox{\NESW} & \eh@nd\\
\end{tabular}%
\egroup%
}
%
% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{\showNWgame}
%
% \begin{macrocode}
%
\newcommand\showNWgame[1][c]%
{%
\bgroup%
\gamesize%
\begin{tabular}[#1]{@{}l@{}l@{}}%
\vtop{\hsize\handwidth\@parboxrestore\c@mm} & \nh@nd\\
\wh@nd & \usebox{\NESW} \\
\end{tabular}%
\egroup%
}
%
% \end{macrocode}
%
% \end{macro}
%
% \section{Bidding}
%
% The bidding environment is defined using a tabular* environment.
% This way the width of the bidding sequence can be controled.
%
% \begin{macrocode}
%
\newenvironment{bidding}[1][t]%
{%
\begin{tabular*}{\bidwidth}[#1]{@{}*{3}{l@{\extracolsep{0pt plus 1fil}}}l@{}}%
\bidderfont{\firstbidd@r} & \bidderfont{\secondbidd@r} &%
\bidderfont{\thirdbidd@r} & \bidderfont{\fourthbidd@r}\\%
\ifx\alln@me\empty%
\else%
\namefont{\firstn@me} & \namefont{\secondn@me} &%
\namefont{\thirdn@me} & \namefont{\fourthn@me}\\%
\fi%
}
%
% what's to be done at the end of the environment
%
{%
\end{tabular*}%
}
%
% \end{macrocode}
%
% \begin{macrocode}
%
\newenvironment{biddingpair}[1][t]%
{%
\begin{tabular*}{0.55\bidwidth}[#1]{l@{\extracolsep{0pt plus 1fil}}l}%
\bidderfont\firstbidd@r & \bidderfont\thirdbidd@r \\%
\ifx\alln@me\empty%
\else%
\namefont\firstn@me & \namefont\thirdn@me \\%
\fi%
}%
%
% what's to be done at the end of the environment
%
{%
\end{tabular*}%
}%
%
% \end{macrocode}
%
% Here is the box that holds the center of the game display.
%
% \begin{macrocode}
%
\newbox{\NESW}
%
% \end{macrocode}
%
% If the user redefines one or more of the commands \verb+\N@+,
% \verb+\E@+, \verb+\S@+ or \verb+\W@+ he should fill the box anew.
% Therefore we supply a command to do that.
%
% \begin{macrocode}
%
\newcommand\renewNESW%
{%
\setbox\NESW\hbox to \handwidth%
{%
\fbox%
{%
\gamesize\smaller\W@\hspace{.3em}%
\rlap{\raisebox{2.6ex}{\N@}}%
\rlap{\raisebox{-2.6ex}{\S@}}%
\phantom{N}\hspace{.3em}\E@%
}%
\hfil\null%
}%
%
% To make sure that some white space appears above and below the box
% we enlarge its height and depth by 1.2ex (orig.: 0.7ex) resp. 0.7ex.
%
\@tempdima=\ht\NESW \advance\@tempdima by 1.2ex \ht\NESW=\@tempdima%
\@tempdima=\dp\NESW \advance\@tempdima by 0.7ex \dp\NESW=\@tempdima%
}
%
% \end{macrocode}
%
% All that's left to do is initialize the box with the default values.
%
% \begin{macrocode}
\renewNESW
% \end{macrocode}
%
% \begin{macro}{\hanghand}
% The macro \verb=\hanghand= puts a hand display in a box. The text
% flows around the box. In order for this to work properly the
% paragraph that is to be printed alongside the box should be long
% enough. If it isn't the text for two paragraphs can be made to
% look like two but be processed as one by \TeX\ by using a macro
% sequence such as \verb+\vadjust{\vskip\parskip}\hfill\break\indent+.
%
% \begin{macrocode}
%
\newcommand\hanghand[4]%
{%
\@drop{\vhand{#1}{#2}{#3}{#4}}%
}
%
% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{\hangNSgame}
%
% \begin{macrocode}
%
\newcommand\hangNSgame%
{%
\@drop%
{%
\vtop%
{%
\hsize\handwidth\@parboxrestore%
\hbox{\c@mm}%
\hbox{\nh@nd}%
\hbox{\usebox{\NESW}}%
\hbox{\sh@nd}%
}%
}%
}
%
% \end{macrocode}
%
% \end{macro}
%
% \iffalse comment
% J.L., we didn't know what the following line was for, so we commented it.
%
%\newcommand\lesshang[1]{\leavevmode\prevgraf=#1}
% \fi
%
% \begin{macro}{\@drop}
% The macro \verb=\@drop= is a simplified version of the one appearing
% in {\tt drop.sty} by {\tt??}. It puts its argument inside an
% \verb=\fbox= and computes the necessary values for
% \verb=\hangindent= and \verb=\hangafter=.
%
% \begin{macrocode}
%
\newcommand\@drop[1]%
{%
{%
\noindent
\setbox8\hbox{\fbox{#1}}%
\count8=\ht8\advance\count8 by\dp8\count1\baselineskip%
\dimen1=.5ex\advance\count8by\dimen1\divide\count8 by\count1%
\advance\count8 by1\relax\dimen8\wd8%
\advance\dimen8 by.5em%
\global\hangindent\dimen8\global\hangafter-\count8%
\hskip-\dimen8\setbox8\hbox to\dimen8{\lower\fboxsep\box8\hss}%
\dp8=0in\ht8=0in\box8%
}%
}
%
% \end{macrocode}
%
% \end{macro}
%
% \section{Internal Macros}
%
% \begin{macro}{\hhand}
% Now we come to the internal macros.
% First we have the horizontal-mode variant of the \verb+\hand+
% macro. This just lists the cards and colours, with appropriate
% spacing. The internal macro \verb+\c@rds+ does the dirty work.
%
% \begin{macrocode}
%
\newcommand\hhand[4]%
{%
\Sp\kern1.5\cardskip\hbox{\c@rds#1!}%
\hspace{2\cardskip}\He\kern1.5\cardskip\hbox{\c@rds#2!}%
\hspace{2\cardskip}\Di\kern1.5\cardskip\hbox{\c@rds#3!}%
\hspace{2\cardskip}\Cl\kern1.5\cardskip\hbox{\c@rds#4!}%
}
%
% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{\vhand}
% Now we come to the vertical-mode variant of the \verb+\hand+
% macro. It doesn't do much, justs adds a parameter in front of the
% four parameters specified by the user and calls another internal
% macro to build the minipage with the cards.
%
% \begin{macrocode}
%
\newcommand\vhand[4]%
{%
\h@nd{t}{#1}{#2}{#3}{#4}%
}
%
% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{\h@nd@}
% \begin{macro}{\h@nd}
% This macro builds a minipage, containing a display of the cards
% of one of the players. The first line will show the spades,
% the second shows the hearts, etc.
% The cards are set in paragraph with a hanging indent from the
% card symbol. This paragraph has a somewhat peculiar layout. The
% first line of this paragraph should always be flush left against
% the card-symbol, but if all the cards don't fit on a single line
% this has to be broken and the rest of the cards will be flush right
% against the righthand side of the minipage. To achieve this we
% specify a infinitely stretchable \verb+\leftskip+, but cancel
% this \verb+\leftskip+ for the first line of the paragraph using the macro
% \verb+\everypar+, which is executed at the start of each paragraph.
% If the user-arguments are empty \verb+\h@nd+ does next to nothing.
% The macro uses \verb+\card+ to format the cards.
%
% \begin{macrocode}
\newcommand\h@nd@[1]%
{%
\begin{minipage}[c]{\handwidth}%
\parskip\z@\parindent\z@%
\rightskip 0\p@ plus 1fill #1%
\end{minipage}%
}
%
% \end{macrocode}
%
% \begin{macrocode}
%
\newcommand\h@nd[5]%
{%
\begin{minipage}[#1]{\handwidth}%
\parskip\z@%
\leftskip 0\p@ plus 1fil \rightskip \z@ \parfillskip \z@%
\hbadness=10000 \everypar{\hskip 0\p@ plus -1fil}%
\def\next{#2}%
\ifx\empty\next%
\relax%
\else%
\@hangfrom{\Sp\hskip1.5\cardskip}{\c@rds#2!}%
\par%
\fi%
\def\next{#3}%
\ifx\empty\next%
\relax%
\else%
\@hangfrom{\He\hskip1.5\cardskip}{\c@rds#3!}%
\par%
\fi%
\def\next{#4}%
\ifx\empty\next%
\relax%
\else%
\@hangfrom{\Di\hskip1.5\cardskip}{\c@rds#4!}%
\par%
\fi%
\def\next{#5}%
\ifx\empty\next%
\relax%
\else%
\@hangfrom{\Cl\hskip1.5\cardskip}{\c@rds#5!}%
\par%
\fi%
\end{minipage}%
}
%
% \end{macrocode}
%
% \end{macro}
%
% \end{macro}
%
% \begin{macro}{\c@rds}
% \begin{macro}{\suit}
% Well finally, here is the definition of \verb+\c@rds+. The function
% of this macro is to take a list of cards like {AHB87}, take it
% apart and insert some white space in between. The amount of space
% inserted is controlled by \verb+\cardskip+. BUT, no white space
% should be inserted between the \verb+1+ and the \verb+0+ of the
% playing card 10, so when a \verb+1+ is encountered it is skipped,
% and the following \verb+0+ will result in a \verb+10+.
% This is accomplished by yet another internal macro, \verb+\c@rd+.
% As long as the second argument to \verb+\c@rds+ is not empty, a
% card is formatted and \verb+\c@rds+ called again. If the second
% argument is empty the macro formats the last card and quits.
% Notice that the calling macro must have delimited the arguments
% to \verb+\c@rds+ with a \verb+!+.
%
% \begin{macrocode}
%
\newcommand\suit[1]%
{%
\c@rds #1!%
}
\newcommand\cards[1]%
{%
\suit{#1}%
}
\def\c@rds#1#2!%
{%
\def\next{#2}%
\ifx\next\empty%
\c@rd{#1}%
\else%
\if#11%
\c@rds#2!%
\else%
\c@rd{#1}\hspace{\cardskip}\c@rds#2!%
\fi%
\fi%
}
%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\c@rd}
% This last macro allows the user to specify either \verb+T+ or
% \verb+10+ or \verb+0+ if he wants to show the playing card 10.
% As a byproduct it also changes a \verb+-+ to \verb+--+ to denote
% a renonce.
%
% \begin{macrocode}
\newcommand\c@rd[1]%
{%
\if#1T%
10%
\else%
\if#10%
10%
\else%
\if#1-%
--%
\else%
#1%
\fi%
\fi%
\fi%
}
%
% \end{macrocode}
% \end{macro}
%
% And now some final commands for showing the cards only in one suit
% for one pair or all players at the table.
%
% \begin{macro}{\onesuitNS}
%
% \begin{macrocode}
%
\newcommand\onesuitNS[2]%
{%
\begin{center}%
\c@rds#1!\\%
$\Box$\\%
\c@rds#2!%
\end{center}%
}
%
% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{\onesuitEW}
%
% \begin{macrocode}
%
\newcommand\onesuitEW[2]%
{%
\begin{center}%
\begin{tabular}{@{}rcl@{}}%
\c@rds#1! & $\Box$ & \c@rds#2! \\%
\end{tabular}%
\end{center}%
}
%
% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{\onesuit}
% The macro \verb+\onesuit+ allows to show (some) cards of only one suit.
% The cards are to be given in the order NESW!
%
% \begin{macrocode}
%
\newcommand\onesuit[4]%
{%
\begin{center}%
\begin{tabular}{@{}rcl@{}}%
& \c@rds#1! \\%
\c@rds#4! & $\Box$ & \c@rds#2! \\%
& \c@rds#3! %
\end{tabular}%
\end{center}%
}
%
% \end{macrocode}
%
% \end{macro}
%
% That's all, folks
% Hope you enjoy
%
\endinput
|