-
Notifications
You must be signed in to change notification settings - Fork 0
/
bridge.tex
150 lines (130 loc) · 3.64 KB
/
bridge.tex
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
\usepackage{color}
\usepackage{fullpage}
\usepackage{longtable}
% Solid heart and diamond symbols for use with color fonts. Solution from
% https://tex.stackexchange.com/questions/9641/filled-diamondsuit-and-heartsuit/9643#9643
\DeclareSymbolFont{extraup}{U}{zavm}{m}{n}
\DeclareMathSymbol{\varheart}{\mathalpha}{extraup}{86}
\DeclareMathSymbol{\vardiamond}{\mathalpha}{extraup}{87}
% The rest is adapted from the bridge-pln package on CTAN:
% https://ctan.org/pkg/bridge-pln
% Suit definitions
\newcommand{\s}{\ensuremath{\spadesuit}}
\newcommand{\h}{\ensuremath{{\color{red}\varheart}}}
\renewcommand{\d}{\ensuremath{{\color{red}\vardiamond}}}
\renewcommand{\c}{\ensuremath{\clubsuit}}
\newcommand{\nt}{\textsc{nt}}
\newcommand{\hand}[4]{{%
%Example: \hand{AKJ765}{AK9}{--}{T983}
\setlength{\tabcolsep}{0.5ex}
\begin{tabular}[t]{rl}
\s\\
\h\\
\d\\
\c\\
\end{tabular}
}}
\newcommand{\NESW}{{
\setlength{\tabcolsep}{0mm}
\begin{centering}
\begin{tabular}[t]{|ccc|}
\hline
&N&\\
~W&&E~{}~\\
&S&\\
\hline
\end{tabular}
\end{centering}
}}
\newcounter{dealno}
\newcommand{\deal}{
\ifdefined\showsolutions
% We use \expandafter to get rid of the \else...\fi before passing
% arguments to the \fulldeal.
\expandafter\fulldeal
\else
\expandafter\isolatedhand
\fi
}
\newcommand{\fulldeal}[6]{
% Arguments are: dealer, vulnerability, N E S W
\begin{tabular}[t]{lll}
\stepcounter{dealno}
\textbf{Deal \arabic{dealno}}&
\begin{tabular}[t]{l}Dlr: #1\\ Vul: #2\end{tabular}\\
#6&\NESW\\
&
\end{tabular}
}
\newcommand{\isolatedhand}[6]{
% Arguments are: dealer, vulnerability, N E S W
% We only want to show dealer, vulnerability, and the South hand
\begin{tabular}{lll}
\stepcounter{dealno}
\textbf{Deal \arabic{dealno}}&
\begin{tabular}[t]{l}
Dlr: #1\\ Vul: #2
\end{tabular}&
#5
\end{tabular}
}
\newcommand{\ouralert}[1]{% Only show the explanation in the solution.
\ifdefined\showsolutions\footnote{#1}\fi%
}
\newcommand{\oppsalert}[1]{% Always show the explanation
\footnote{#1}%
}
\newenvironment{bidding}{
\begin{minipage}[t]{2in}
\begin{tabular}{llll}%
\emph{West}&
\emph{North}&
\emph{East}&
\emph{South}\\}{
\end{tabular}%
\end{minipage}%
}
% It might be simplest to just check if \showsolutions is defined once at the
% very beginning and change the definition of \problem in response to that. but
% this way, we can define it and undefine it in the middle of the document and
% get interesting results. This is particularly useful during testing and
% debugging.
\newcommand{\problem}{%
\ifdefined\showsolutions
\expandafter\problemwithsolution
\else
\expandafter\problemwithoutsolution
\fi
}
\newcommand{\problemwithsolution}[5]{
% Arguments are: deal, bidding, answer, explanation, debugging reference
\hline\\
\begin{tabular}[t]{c}
#1\\\\#2
\end{tabular}
&
\begin{minipage}[t]{2.58in}
Answer: #3
~ % Extra spearation between the short answer and the explanation.
#4 % TODO: Maybe just change the paragraph separation length?
~ % Note that using \\ in a minipage gives "underful hbox" errors.
{\footnotesize Debug Ref.: #5}
\end{minipage}
\vspace*{0.5ex}\\
}
\newcommand{\problemwithoutsolution}[5]{
% Arguments are: deal, bidding, answer, explanation, debugging reference
% We surround the whole thing with blank lines to give the hand a little more
% room to be considered on its own.
\hline\\
#1\\
\\
}
\newenvironment{problemset}{
\begin{center}
\begin{longtable}[H]{ll}
}{
\hline
\end{longtable}
\end{center}
}