-
Notifications
You must be signed in to change notification settings - Fork 10
/
bingocards.tex
177 lines (142 loc) · 6.13 KB
/
bingocards.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
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
\documentclass[10pt]{article}
\usepackage[left=1.0in,right=1.0in,top=1.0in,bottom=1.0in]{geometry}
% mostly stolen from
% http://tex.stackexchange.com/questions/63357/automatically-generated-bingo-cards
%
% but cleaned up a little, and with a few additions.
%
% Jesse Hamner, 2016-2020
\usepackage{xstring}
\usepackage{pgffor}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{xparse}
\usepackage{tabularx}
\usepackage{amssymb}
\input{random.tex} % this isn't supposed to exist yet, so if you get errors about it, ignore them
\newcount\randomnum
% The LaTeX3 coding language, -expl3-, uses : and _ as 'letters' in
% function and variable names.
% setting expl syntax to "on" allows use of -expl3- code-level material
% in a document.
\ExplSyntaxOn % underscores are no longer a problem, for one thing
\seq_new:N \g_my_items_seq
\seq_new:N \l_my_tmp_items_seq
\seq_new:N \g_my_randomized_seq
\int_new:N \l_tmp_int
\msg_new:nnnn {bingo} {Too~few~items!} {Provide~at~least~24~items!}{}
\cs_generate_variant:Nn \seq_item:Nn {Nx}
\cs_generate_variant:Nn \seq_remove_all:Nn {Nx}
\NewDocumentCommand {\myItems} {m}
{
\seq_clear:N \g_my_items_seq % clear item list
\seq_gset_split:Nnn \g_my_items_seq {;} {#1} % put item list into g_my_items_seq
\int_compare:nNnT {\seq_count:N \g_my_items_seq} < {24} % check whether there are enough items
{
\msg_error:nn {bingo} {Too~few~items!}
}
}
\NewDocumentCommand{\setItems}{}
{
\seq_set_eq:NN \l_my_tmp_items_seq \g_my_items_seq % put in temp seq so that multiple cards can be produced
\prg_replicate:nn {24} % generate random list of 24 items
{
\int_set:Nn \l_tmp_int {\seq_count:N \l_my_tmp_items_seq} % set current length of list
\setrannum{\randomnum}{1}{ % choose random num up to length of seq
\int_use:N \l_tmp_int
}
\seq_put_right:Nx \g_my_randomized_seq { % grab corresponding item and put in tmp seq
\seq_item:Nn \l_my_tmp_items_seq {\the\randomnum}
}
\seq_remove_all:Nx \l_my_tmp_items_seq { % delete that item from temp seq
\seq_item:Nn \l_my_tmp_items_seq {\the\randomnum}
}
}
\seq_clear:N \l_my_tmp_items_seq % clear temp seq when done
}
\NewDocumentCommand {\NodeText}{}
{
\seq_gpop_right:NN \g_my_randomized_seq \l_tmpa_tl % pop item from randomized seq into token list
\tl_use:N \l_tmpa_tl % use that item.
}
\ExplSyntaxOff
\def\NumOfColumns{5}%
\def\Sequence{1, 2, 3, 4, 5}%
\newcommand{\sep}{1mm}
% make a nice identifier for the card (perhaps there is more than one
% presidential debate, etc.)
\newcommand{\biglabel}{\vspace{0.2in}\begin{center}
\begin{LARGE}
Bingo
Super Bowl
13 February 2022
\end{LARGE}
\end{center}
}
\newcommand{\freespace}{
\filldraw[fill=gray!35, draw=black] ($(\col,-\row)-(1,1)$) rectangle ($(\col,-\row)$) ;
% "Free Space" -- that's the joke:
\node [scale=1.2] at ($(\col,-\row)-(0.5,0.3)$) {Candidate};
\node [scale=1.2] at ($(\col,-\row)-(0.5,0.5)$) {Talks Past};
\node [scale=1.2] at ($(\col,-\row)-(0.5,0.7)$) {Allotted Time};
}
% use Donald_Trump_official_portrait.jpg as free space image:
\renewcommand{\freespace}{
\filldraw[fill=gray!90, draw=black] ($(\col,-\row)-(1,1)$) rectangle ($(\col,-\row)$) ;
\node [scale=1.2] at ($(\col,-\row)-(0.5,0.5)$) {\includegraphics[scale=0.16, clip=true, trim=0 0 0 0]{nfl_logo.png}};
}
% If you want a more standard free space square:
%\renewcommand{\freespace}{
% \filldraw[fill=gray!35, draw=black] ($(\col,-\row)-(1,1)$) rectangle ($(\col,-\row)$) ;
% \node [scale=1.2] at ($(\col,-\row)-(0.5,0.4)$) {Free};
% \node [scale=1.2] at ($(\col,-\row)-(0.5,0.6)$) {Space};
%}
% Although it doesn't save any code by breaking this out into its own
% function (subroutine), it makes the code easier to parse down below
% in the for loop:
\newcommand{\drawthecard}{
\begin{tikzpicture}[draw=black, thick, x=\Size,y=\Size]
\foreach \row in \Sequence{%
\foreach \col in \Sequence {%
\pgfmathtruncatemacro{\value}{\col+\NumOfColumns*(\row-1)}
\pgfmathsetmacro{\ColRowProduce}{\col*\row} % 3 x 3 = 9
\IfEq{\ColRowProduce}{9}{% If is center square, do the \freespace command:
\freespace
}
{ % if it is not the center square:
\node [Square] at ($(\col,-\row)-(0.5,0.5)$) {\large \NodeText};
}
}
}
\end{tikzpicture}
}
\newcommand{\Size}{3.1cm}
\newcommand{\Sizeinner}{3.0cm}
\tikzset{Square/.style={
inner sep=0pt,
text width=\Sizeinner,
minimum size=\Size,
draw=black,
align=center
}
}
\begin{document}
\pagestyle{empty}
%\myItems{this;will;produce;an;error;because;there;aren't;enough;items}
% These items should be contained in a separate file, formatted
% so that it's easier to read and change without altering the original
% LaTeX file:
%\myItems{``Believe me"; Tax returns; Benghazi; Shot of Bill Clinton in audience; Clinton Foundation; ``Make America Great Again"; Tim Kaine; Build ``the wall"; Heckler interrupts debate; Candidate talks past allotted time; Gun ban; NAFTA; Black Lives Matter; ``Basket of deplorables"; Alt-right; Florida; Mike Pence; Moderator interrupts candidate; Free market; ``My record shows ...''; Terrorism; Candidate demands an apology; John McCain; Pam Bondi; Health of candidate; Trump charity; ``Liberal media"; Shot of Melania Trump in audience; ``What do you have to lose?"; China; Taxes; Climate change; Middle East; Emails; ``I've employed thousands of people"; Joke about Trump's hair; Candidate says the other is ``disqualified"; Clinton mentions children--any children; Emails; Temperament; Transparency; ``Stronger Together"; NAFTA; Bankruptcy; Birther; Audience laughs; NATO; ``Tremendous success"; ``I can fix it"; President Obama; Ronald Reagan; Audience claps; Rigged; Trump says he was against the Iraq War; The Second Amendment; Trade agreement; Skittles; Income inequality; Top 1\%; Political correctness }
% read in the list of 'squares' from the file you have written:
\input{superbowlbingolist.tex}
% start a for-loop to make each page (its own card)
\foreach \n in {0,...,49}{
% select and randomize the entries:
\setItems
% actually draw the card:
\drawthecard
% add the label text:
\biglabel
} % done with the loop
\end{document}
% <EOF>