| 1 |
% \iffalse |
| 2 |
% <*chit> |
| 3 |
% -------------------------------------------------------------------- |
| 4 |
% \fi |
| 5 |
% \subsubsection{Table of chits} |
| 6 |
% |
| 7 |
% \begin{macrocode} |
| 8 |
\tikzset{ |
| 9 |
chit/cell background/.style={draw=black}, |
| 10 |
%% Define to not dp anyting to disable wings |
| 11 |
chit/cell wings/.style={ |
| 12 |
dashed, |
| 13 |
dash pattern=on 0pt off 3pt on 3pt off 0pt, |
| 14 |
draw=black}, |
| 15 |
%chit/cell background flipped/.style={fill=black}, |
| 16 |
blank chit/.style={/chit/frame={draw=none,fill=none}}, |
| 17 |
chit/grid lines/.style={dashed}, |
| 18 |
} |
| 19 |
% \end{macrocode} |
| 20 |
% |
| 21 |
% These macros are used when we set tables of chits. This allows us |
| 22 |
% to define blank spaces in the table by giving the element |
| 23 |
% \texttt{blank~chit}. |
| 24 |
% |
| 25 |
% \begin{macrocode} |
| 26 |
\def\chit@blank{blank chit} |
| 27 |
\def\chit@cellbg(#1,#2)#3{% |
| 28 |
\draw[chit/cell background](#1-#3/2,#2-#3/2) rectangle++(#3,#3); |
| 29 |
} |
| 30 |
\def\chit@celldblbg(#1,#2)#3{% |
| 31 |
\draw[chit/cell background,chit/cell background flipped/.try]% |
| 32 |
(#1-#3/2,#2-#3/2) rectangle++(#3,#3); |
| 33 |
} |
| 34 |
% \end{macrocode} |
| 35 |
% |
| 36 |
% \begin{Macro}{\ifchits@reset} |
| 37 |
% |
| 38 |
% This `if' controls whether to reset the coordinates to the origin |
| 39 |
% when \cs{chits} is called. If true, then reset for a new table. |
| 40 |
% |
| 41 |
% \begin{macrocode} |
| 42 |
\newif\ifchits@reset\chits@resettrue |
| 43 |
% \end{macrocode} |
| 44 |
% \end{Macro} |
| 45 |
% |
| 46 |
% \begin{enumerate} |
| 47 |
% \item column |
| 48 |
% \item row |
| 49 |
% \item width |
| 50 |
% \item number of columns |
| 51 |
% \end{enumerate} |
| 52 |
% |
| 53 |
% \begin{Macro}{\chits,\@chits,\chit@sng@cellupdate} |
| 54 |
% \begin{macrocode} |
| 55 |
\def\chit@sng@cellupdate(#1,#2)#3#4{% |
| 56 |
\chit@dbg{2}{Current `#1' vs `#4'*(`#3'+1)} |
| 57 |
\pgfmathparse{ifthenelse(#1>=#4*(#3-1),#2-#4,#2)}% |
| 58 |
\xdef#2{\pgfmathresult}% |
| 59 |
\pgfmathparse{ifthenelse(#1>=#4*(#3-1),0,#1+#4)}% |
| 60 |
\xdef#1{\pgfmathresult}% |
| 61 |
} |
| 62 |
% \end{macrocode} |
| 63 |
% |
| 64 |
% \begin{macrocode} |
| 65 |
\def\chit@cell@frame#1#2{% |
| 66 |
\coordinate(cell@frame@north east) at ($(#1.north east)+( #2/2, #2/2)$); |
| 67 |
\coordinate(cell@frame@north west) at ($(#1.north west)+(-#2/2, #2/2)$); |
| 68 |
\coordinate(cell@frame@south east) at ($(#1.south east)+( #2/2,-#2/2)$); |
| 69 |
\coordinate(cell@frame@south west) at ($(#1.south west)+(-#2/2,-#2/2)$); |
| 70 |
\draw[chit/cell background,fill=none,scale line widths,line width=#2cm] |
| 71 |
(cell@frame@south west) rectangle (cell@frame@north east); |
| 72 |
\draw[scale line widths,line width=#2cm,chit/cell wings=10pt,fill=none,scale line widths,line width=#2cm] |
| 73 |
(cell@frame@north east)--++( 0,10*#2) |
| 74 |
(cell@frame@north east)--++( 10*#2,0) |
| 75 |
(cell@frame@north west)--++( 0,10*#2) |
| 76 |
(cell@frame@north west)--++(-10*#2,0) |
| 77 |
(cell@frame@south east)--++( 0,-10*#2) |
| 78 |
(cell@frame@south east)--++( 10*#2,0) |
| 79 |
(cell@frame@south west)--++( 0,-10*#2) |
| 80 |
(cell@frame@south west)--++(-10*#2,0) |
| 81 |
; |
| 82 |
} |
| 83 |
% \end{macrocode} |
| 84 |
% The stared version (\cs{chits*}) of this macro continues the |
| 85 |
% previously set chit table. |
| 86 |
% |
| 87 |
% \begin{macrocode} |
| 88 |
\def\chits{% |
| 89 |
\@ifstar{\chits@resetfalse\@chits}{\chits@resettrue\@chits}} |
| 90 |
% \end{macrocode} |
| 91 |
% |
| 92 |
% \begin{enumerate} |
| 93 |
% \item Chits. List (or list of list) of chit styles. |
| 94 |
% \item Number of columns |
| 95 |
% \item Size of cells |
| 96 |
% \end{enumerate} |
| 97 |
% |
| 98 |
% \begin{macrocode} |
| 99 |
\newcount\wg@col |
| 100 |
\newcount\wg@row |
| 101 |
\def\@chits#1#2#3{ |
| 102 |
\ifchits@reset |
| 103 |
%\def\r{0}% |
| 104 |
%\def\c{0}% |
| 105 |
\coordinate(wg@next) at (0,0); |
| 106 |
\wg@col=1 |
| 107 |
\wg@row=1 |
| 108 |
\fi |
| 109 |
\chit@dbg{1}{Chits to make: #1}% |
| 110 |
\foreach[count=\ti from 0] \t/\x in #1{% |
| 111 |
\chit@dbg{2}{Turn `\t' with option `\x'} |
| 112 |
\ifx\t\empty\else% |
| 113 |
\foreach \u/\m in \t{% |
| 114 |
\ifx\u\empty\else% |
| 115 |
\chit@dbg{2}{Next chit `\u' with possible multiplicity `\m'}% |
| 116 |
\ifx\m\@empty\def\m{1}\fi% |
| 117 |
\ifx\u\m\def\m{1}\fi% |
| 118 |
\chit@dbg{2}{Next chit `\u' multiplicity `\m'}% |
| 119 |
\foreach \n in {1,...,\m}{% |
| 120 |
\ifx\u\chit@blank% |
| 121 |
\chit@dbg{3}{Ignoring blank chit:\u}% |
| 122 |
\else% |
| 123 |
\ifx\u\chit@oob@vspacer% |
| 124 |
\chit@dbg{3}{Ignoring vertical spacer:\u}% |
| 125 |
\else |
| 126 |
\ifx\u\chit@oob@spacer% |
| 127 |
\chit@dbg{3}{Ignoring horizontal spacer:\u}% |
| 128 |
\else |
| 129 |
% \chit@cellbg(\c,\r){#3}% |
| 130 |
%\chit[\u=\ti](\c,\r)% |
| 131 |
\chit[\u=\ti](wg@next)(wg@chit)% |
| 132 |
\chit@cell@frame{wg@chit}{#3} |
| 133 |
\global\advance\wg@col1 |
| 134 |
\ifnum\wg@col>#2% |
| 135 |
\path |
| 136 |
let |
| 137 |
\p1=([email protected]), |
| 138 |
\p2=([email protected]), |
| 139 |
\p3=(wg@chit), |
| 140 |
\n1={\y3-\y1+\y2-#3cm} in |
| 141 |
coordinate(wg@next) at (0,\n1); |
| 142 |
\global\wg@col=1 |
| 143 |
\global\advance\wg@row1 |
| 144 |
\chit@dbg{10}{Row row, next column `\the\wg@col'} |
| 145 |
\else |
| 146 |
\path |
| 147 |
let |
| 148 |
\p1=([email protected]), |
| 149 |
\p2=([email protected]), |
| 150 |
\p3=(wg@chit), |
| 151 |
\n1={\x3+\x1-\x2+#3cm} in |
| 152 |
coordinate(wg@next) at (\n1,\y3); |
| 153 |
\chit@dbg{10}{Next column `\the\wg@col'} |
| 154 |
\fi |
| 155 |
%\chit@sng@cellupdate(\c,\r){#2}{#3}% |
| 156 |
\fi% |
| 157 |
\fi% |
| 158 |
\fi% |
| 159 |
}% |
| 160 |
\fi% |
| 161 |
}% |
| 162 |
\fi% |
| 163 |
}% |
| 164 |
\chit@dbg{10}{Table is `\the\wg@col'x`\the\wg@row'} |
| 165 |
\@ifnextchar;{\@gobble}{}} |
| 166 |
% \end{macrocode} |
| 167 |
% \end{Macro} |
| 168 |
% \begin{Macro}{\chitgrid} |
| 169 |
% \begin{enumerate} |
| 170 |
% \item columns |
| 171 |
% \item rows |
| 172 |
% \item cell-size |
| 173 |
% \end{enumerate} |
| 174 |
% |
| 175 |
% \begin{macrocode} |
| 176 |
\def\chitgrid#1#2#3{% |
| 177 |
\pgfmathparse{#3/2}\edef\rmin{\pgfmathresult}% |
| 178 |
\pgfmathparse{#2*#3-#3/2}\edef\rmax{\pgfmathresult}% |
| 179 |
%\draw[red](-#3/2,\rmin)rectangle(#3*#1-#3/2,-\rmax); |
| 180 |
\foreach \cc in {0,...,#1}{ |
| 181 |
\draw[chit/grid lines] (\cc*#3-#3/2,3*#3/4)--(\cc*#3-#3/2,-\rmax-#3/4);} |
| 182 |
%\chit@dbg{0}{Drawing horizontal lines from `\rmin, `-\rmin', ..., `-\rmax'} |
| 183 |
\foreach \rr in {\rmin,-\rmin,...,-\rmax}{ |
| 184 |
%\chit@dbg{0}{Horizontal line at `\rr'} |
| 185 |
\draw[chit/grid lines] (-3*#3/4,\rr)--(#1*#3-#3/4,\rr);} |
| 186 |
} |
| 187 |
% \end{macrocode} |
| 188 |
% \end{Macro} |
| 189 |
% |
| 190 |
% \begin{Macro}{\doublechits, |
| 191 |
% \@doublechits, |
| 192 |
% \chit@dbl@cellupdate, |
| 193 |
% \chit@dbl@flip} |
| 194 |
% \begin{enumerate} |
| 195 |
% \item coordinates |
| 196 |
% \item coordinates |
| 197 |
% \item cell-size |
| 198 |
% \end{enumerate} |
| 199 |
% |
| 200 |
% \begin{macrocode} |
| 201 |
\def\chit@dbl@flip(#1,#2)#3{% |
| 202 |
\pgfmathparse{-#1}% |
| 203 |
\xdef\mc{\pgfmathresult}% |
| 204 |
} |
| 205 |
% \end{macrocode} |
| 206 |
% |
| 207 |
% \begin{enumerate} |
| 208 |
% \item coordinates |
| 209 |
% \item coordinates |
| 210 |
% \item Number of columns |
| 211 |
% \item cell-size |
| 212 |
% \end{enumerate} |
| 213 |
% |
| 214 |
% \begin{macrocode} |
| 215 |
\def\chit@dbl@cellupdate(#1,#2)#3#4{% |
| 216 |
\pgfmathparse{ifthenelse(#1<-#4/2,#2,#4+#2)}% |
| 217 |
\xdef#2{\pgfmathresult}% |
| 218 |
\pgfmathparse{ifthenelse(#1<-#4/2,#4+#1,-(#3-.5)*#4)}% |
| 219 |
\xdef#1{\pgfmathresult}% |
| 220 |
} |
| 221 |
% \end{macrocode} |
| 222 |
% |
| 223 |
% \begin{enumerate} |
| 224 |
% \item List of list of keys |
| 225 |
% \item Number of columns |
| 226 |
% \item size of each cell |
| 227 |
% \end{enumerate} |
| 228 |
% |
| 229 |
% The stared version (\cs{doublechits*}) of this macro continues the |
| 230 |
% previously set chit table. |
| 231 |
% |
| 232 |
% \begin{macrocode} |
| 233 |
\def\doublechits{% |
| 234 |
\@ifstar{\chits@resetfalse\@doublechits}{\chits@resettrue\@doublechits}} |
| 235 |
% \end{macrocode} |
| 236 |
% |
| 237 |
% \begin{enumerate} |
| 238 |
% \item List (or list of list) of counters |
| 239 |
% \item Max number columns (for front) |
| 240 |
% \item Extra spacing |
| 241 |
% \end{enumerate} |
| 242 |
% |
| 243 |
% \begin{macrocode} |
| 244 |
\newdimen\chit@w |
| 245 |
\newdimen\chit@h |
| 246 |
\def\@doublechits#1#2#3{% |
| 247 |
\chit@dbg{1}{Setting double-sided chits: #1} |
| 248 |
\ifchits@reset% |
| 249 |
%\pgfmathparse{-(#2-.5)*#3} |
| 250 |
%\xdef\c{\pgfmathresult} |
| 251 |
%\def\r{0} |
| 252 |
\coordinate(wg@next) at (0,0);% |
| 253 |
\coordinate(wg@fnxt) at (0,0);% |
| 254 |
\wg@col=1% |
| 255 |
\wg@row=1% |
| 256 |
\chit@w=0pt% |
| 257 |
\chit@h=0pt% |
| 258 |
\fi% |
| 259 |
% |
| 260 |
\foreach[count=\ti from 0] \t/\x in #1{ |
| 261 |
\ifx\t\empty\else% |
| 262 |
\foreach \u/\m in \t{ |
| 263 |
\ifx\u\empty\else |
| 264 |
\ifx\m\@empty\def\m{1}\else% |
| 265 |
\ifx\u\m\def\m{1}\fi\fi |
| 266 |
\chit@dbg{2}{`\u'=`\m' (\c,\r)} |
| 267 |
\foreach \n in {1,...,\m}{% |
| 268 |
\ifx\u\chit@blank |
| 269 |
\chit@dbg{3}{Ignoring blank chit:\u} |
| 270 |
\else |
| 271 |
\ifx\u\chit@oob@vspacer% |
| 272 |
\chit@dbg{3}{Ignoring vertical spacer:\u}% |
| 273 |
\else |
| 274 |
\ifx\u\chit@oob@spacer% |
| 275 |
\chit@dbg{3}{Ignoring horizontal spacer:\u}% |
| 276 |
\else |
| 277 |
\chit@dbg{10}{Drawing `\u' at wg@next} |
| 278 |
\chit[\u=\ti](wg@next)(wg@chit)% |
| 279 |
\chit@cell@frame{wg@chit}{#3} |
| 280 |
\ifdim\chit@w=0pt |
| 281 |
\pgfextractx\chit@w{\pgfpointanchor{wg@chit}{east}}% |
| 282 |
\pgfextractx\wg@tmpa{\pgfpointanchor{wg@chit}{west}}% |
| 283 |
\advance\chit@w-\wg@tmpa% |
| 284 |
\global\advance\chit@w#3cm% |
| 285 |
\pgfextracty\chit@h{\pgfpointanchor{wg@chit}{north}}% |
| 286 |
\pgfextracty\wg@tmpa{\pgfpointanchor{wg@chit}{south}}% |
| 287 |
\advance\chit@h-\wg@tmpa% |
| 288 |
\global\advance\chit@h#3cm% |
| 289 |
\fi |
| 290 |
\ifnum\wg@col=1 |
| 291 |
\pgfextractx\wg@tmpa{\pgfpointanchor{wg@chit}{center}}% |
| 292 |
\advance\wg@tmpa+\chit@w% |
| 293 |
\coordinate(wg@fnxt) at ($(wg@chit)+(\the\chit@w,0pt)$); |
| 294 |
%\coordinate(wg@fnxt |
| 295 |
%\chit@dbg{10}{Calculating wg@fnxt since `\the\wg@col'==1} |
| 296 |
%\path |
| 297 |
%let |
| 298 |
%\p1=([email protected]), |
| 299 |
%\p2=([email protected]), |
| 300 |
%\p3=(wg@chit), |
| 301 |
%\n1={\x3+\x1-\x2+#3cm} in |
| 302 |
%coordinate(wg@fnxt) at (\n1,\y3); |
| 303 |
\fi |
| 304 |
%\chit@dbg{10}{Drawing `\u\space flipped' at wg@fnxt} |
| 305 |
\chit[\u\space flipped=\ti, |
| 306 |
zone turn=\t, |
| 307 |
zone mult=\n](wg@fnxt)(wg@flip)% |
| 308 |
\chit@cell@frame{wg@flip}{#3} |
| 309 |
\chit@dbg{10}{Next column: `\the\wg@col'} |
| 310 |
\ifnum\wg@col=1 |
| 311 |
\ifnum\wg@row=1 |
| 312 |
\coordinate(wg@table@top) at ([email protected] east); |
| 313 |
\fi |
| 314 |
\coordinate(wg@table@bot) at ([email protected] east); |
| 315 |
\fi |
| 316 |
\global\advance\wg@col1 |
| 317 |
\ifnum\wg@col>#2% |
| 318 |
% \path |
| 319 |
% let |
| 320 |
% \p1=([email protected]), |
| 321 |
% \p2=([email protected]), |
| 322 |
% \p3=(wg@chit), |
| 323 |
% \n1={\y3-\y1+\y2-#3cm} in %1.21991 |
| 324 |
% coordinate(wg@next) at (0,\n1); |
| 325 |
\coordinate(wg@next) at (0,-\wg@row\chit@h); |
| 326 |
\global\wg@col=1 |
| 327 |
\global\advance\wg@row1 |
| 328 |
\chit@dbg{10}{Row row, next column `\the\wg@col'} |
| 329 |
\else |
| 330 |
% \path |
| 331 |
% let |
| 332 |
% \p1=([email protected]), |
| 333 |
% \p2=([email protected]), |
| 334 |
% \p3=(wg@chit), |
| 335 |
% \p4=([email protected]), |
| 336 |
% \p5=([email protected]), |
| 337 |
% \p6=(wg@flip), |
| 338 |
% \n1={\x3-\x1+\x2-#3cm}, |
| 339 |
% \n2={\x6+\x4-\x5+#3cm} in |
| 340 |
% coordinate(wg@next) at (\n1,\y3) |
| 341 |
% coordinate(wg@fnxt) at (\n2,\y6); |
| 342 |
\coordinate(wg@next) at ($(wg@chit)+(-\the\chit@w,0)$); |
| 343 |
\coordinate(wg@fnxt) at ($(wg@flip)+(+\the\chit@w,0)$); |
| 344 |
\chit@dbg{10}{Next column `\the\wg@col'} |
| 345 |
\fi |
| 346 |
\fi% |
| 347 |
\fi% |
| 348 |
\fi% |
| 349 |
}% |
| 350 |
\fi% |
| 351 |
}% |
| 352 |
\fi% |
| 353 |
}% |
| 354 |
\draw[dashed,scale line widths](wg@table@top)--++(0,.4); |
| 355 |
\draw[dashed,scale line widths](wg@table@bot)--++(0,-.4); |
| 356 |
\draw[dashed,scale line widths,{Stealth[]}-] |
| 357 |
($(wg@table@top)+(0,.2)$) -- ++(.5,0) |
| 358 |
node[transform shape,anchor=west]{Back}; |
| 359 |
\draw[dashed,scale line widths,{Stealth[]}-] |
| 360 |
($(wg@table@top)+(0,.2)$) -- ++(-.5,0) |
| 361 |
node[transform shape,anchor=east]{Front}; |
| 362 |
\draw[dashed,scale line widths,{Stealth[]}-] |
| 363 |
($(wg@table@bot)+(0,-.2)$) -- ++(.5,0) |
| 364 |
node[transform shape,anchor=west]{Back}; |
| 365 |
\draw[dashed,scale line widths,{Stealth[]}-] |
| 366 |
($(wg@table@bot)+(0,-.2)$) -- ++(-.5,0) |
| 367 |
node[transform shape,anchor=east]{Front}; |
| 368 |
% \draw[dashed,<-] (#3/5,-2*#3/3)--(#3/2,-2*#3/3) node[transform shape,anchor=west]{Back};% |
| 369 |
% \draw[dashed,<-] (-#3/5,-2*#3/3)--(-#3/2,-2*#3/3) node[transform shape,anchor=east]{Front};% |
| 370 |
% \foreach \cc in {0,...,#2}{ |
| 371 |
% \draw[dashed] (\cc*#3,-3*#3/4)--(\cc*#3,\r-#3/4); |
| 372 |
% \draw[dashed] (-\cc*#3,-3*#3/4)--(-\cc*#3,\r-#3/4);} |
| 373 |
% \pgfmathparse{#3/2}\edef\rmin{\pgfmathresult}% |
| 374 |
% \chit@dbg{0}{Drawing horizontal lines from `-\rmin, `\rmin', ..., `\r'} |
| 375 |
% \foreach \rr in {-\rmin,\rmin,...,\r}{ |
| 376 |
% \chit@dbg{0}{Horizontal line at `\rr'} |
| 377 |
% \draw[dashed] (-#2*#3-#3/4,\rr)--(#2*#3+#3/4,\rr);} |
| 378 |
\@ifnextchar;{\@gobble}{}} |
| 379 |
% \end{macrocode} |
| 380 |
% \end{Macro} |
| 381 |
% |
| 382 |
% \begin{Macro}{\doublechitgrid} |
| 383 |
% \begin{enumerate} |
| 384 |
% \item columns |
| 385 |
% \item rows |
| 386 |
% \item cell-size |
| 387 |
% \end{enumerate} |
| 388 |
% |
| 389 |
% \begin{macrocode} |
| 390 |
\def\doublechitgrid#1#2#3{% |
| 391 |
\message{^^JWARNING - the grid table might be messed up!} |
| 392 |
%\iffalse |
| 393 |
\pgfmathparse{#3/2}\edef\rmin{\pgfmathresult}% |
| 394 |
\pgfmathparse{#2*#3-#3/2}\edef\rmax{\pgfmathresult}% |
| 395 |
\foreach \cc in {0,...,#1}{ |
| 396 |
\draw[chit/grid lines] (\cc*#3+\rmin,3*#3/4)--(\cc*#3+\rmin,-\rmax-#3/4); |
| 397 |
\draw[chit/grid lines] (-\cc*#3+\rmin,3*#3/4)--(-\cc*#3+\rmin,-\rmax-#3/4);} |
| 398 |
%\chit@dbg{0}{Drawing horizontal lines from `-\rmin, `\rmin', ..., `\rmax'} |
| 399 |
\foreach \rr in {\rmin,-\rmin,...,-\rmax}{ |
| 400 |
\chit@dbg{0}{Horizontal line at `\rr'} |
| 401 |
\draw[chit/grid lines] (-#1*#3-#3/4+\rmin,\rr)--(#1*#3+#3/4+\rmin,\rr);} |
| 402 |
%\fi |
| 403 |
} |
| 404 |
% \end{macrocode} |
| 405 |
% \end{Macro} |
| 406 |
% \iffalse |
| 407 |
% </chit> |
| 408 |
% -------------------------------------------------------------------- |
| 409 |
% \fi |