mirror of
https://gitlab.com/MisterBiggs/latex-bingo.git
synced 2025-06-15 22:56:44 +00:00
Initial commit of tex and python files
This commit is contained in:
commit
8a3e5cfece
BIN
bingocards.pdf
Normal file
BIN
bingocards.pdf
Normal file
Binary file not shown.
137
bingocards.tex
Normal file
137
bingocards.tex
Normal file
@ -0,0 +1,137 @@
|
||||
\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
|
||||
%
|
||||
% with a few additions myself
|
||||
% Jesse Hamner, 2016
|
||||
|
||||
\usepackage{xstring}
|
||||
\usepackage{pgffor}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{calc}
|
||||
\usepackage{xparse}
|
||||
|
||||
\input{random.tex}
|
||||
\newcount\randomnum
|
||||
\ExplSyntaxOn
|
||||
|
||||
\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 in seq
|
||||
\int_compare:nNnT {\seq_count:N \g_my_items_seq} < {24} {\msg_error:nn {bingo} {Too~few~items!}} % check whether there are enough 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}{\int_use:N \l_tmp_int} % choose random num up to length of seq
|
||||
\seq_put_right:Nx \g_my_randomized_seq {\seq_item:Nn \l_my_tmp_items_seq {\the\randomnum}}% grab corresponding item and put in tmp seq
|
||||
\seq_remove_all:Nx \l_my_tmp_items_seq {\seq_item:Nn \l_my_tmp_items_seq {\the\randomnum}}%delete that item from temp seq
|
||||
}
|
||||
\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 (in case, say, there is more than one
|
||||
% presidential debate, etc.)
|
||||
\newcommand{\biglabel}{\vspace{0.2in}\begin{center}
|
||||
\begin{LARGE}
|
||||
Rawlins Hall Bingo
|
||||
|
||||
First Presidential Debate
|
||||
|
||||
25 September 2016
|
||||
|
||||
\end{LARGE}
|
||||
\end{center}
|
||||
}
|
||||
|
||||
% 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}
|
||||
\IfEq{\ColRowProduce}{9}{% If is center square:
|
||||
\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}; }{
|
||||
\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 are all contained in a separate file, deliberately broken out
|
||||
% so that it's easier to read and parse without messing with 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'
|
||||
\input{bingolist.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>
|
BIN
bingochecklist.pdf
Normal file
BIN
bingochecklist.pdf
Normal file
Binary file not shown.
45
bingochecklist.tex
Normal file
45
bingochecklist.tex
Normal file
@ -0,0 +1,45 @@
|
||||
\documentclass[12pt]{article}
|
||||
\usepackage{tabularx}
|
||||
\usepackage{xcolor}
|
||||
\usepackage{longtable}
|
||||
\usepackage{amsmath, amssymb}
|
||||
\usepackage{marvosym}
|
||||
\usepackage[left=1.0in,right=1.1in,top=1.0in,bottom=0.75in]{geometry}
|
||||
|
||||
\newcommand{\sep}{1mm}
|
||||
\newcommand{\negsep}{-3mm}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\begin{center}
|
||||
\begin{Large}
|
||||
Checklist for debate bingo boxes
|
||||
\end{Large}
|
||||
\vspace{0.15in}
|
||||
|
||||
Rawlins Hall
|
||||
|
||||
First Presidential Debate
|
||||
|
||||
September 26, 2016
|
||||
|
||||
\end{center}
|
||||
|
||||
\begin{longtable}{l p {3.0in} }
|
||||
|
||||
Found & Item \\[\sep]
|
||||
\hline\\[\negsep]
|
||||
\endfirsthead
|
||||
|
||||
Found & Item \\[\sep]
|
||||
\hline\\[\negsep]
|
||||
\endhead
|
||||
|
||||
\hline\hline
|
||||
\endfoot
|
||||
|
||||
\input{checklist1.tex}
|
||||
|
||||
\end{longtable}
|
||||
|
||||
\end{document}
|
95
bingolist.tex
Normal file
95
bingolist.tex
Normal file
@ -0,0 +1,95 @@
|
||||
\myItems{Believe me;
|
||||
Make America Great Again;
|
||||
Build a/the wall;
|
||||
Liberal media;
|
||||
What do you have to lose?;
|
||||
I've employed thousands of people;
|
||||
Tremendous success;
|
||||
I can fix it;
|
||||
Political correctness;
|
||||
We don't \emph{win} anymore;
|
||||
Crooked Hillary;
|
||||
Low energy;
|
||||
Rigged;
|
||||
Benghazi;
|
||||
Florida;
|
||||
China;
|
||||
Syria;
|
||||
Israel;
|
||||
Iran;
|
||||
Mexico;
|
||||
Russia;
|
||||
%Candidate talks past allotted time;
|
||||
%Moderator interrupts candidate;
|
||||
Moderator becomes visibly frustrated;
|
||||
Candidate demands an apology;
|
||||
Heckler interrupts debate;
|
||||
%Joke about Trump's hair;
|
||||
Unqualified;
|
||||
Clinton mentions children--\emph{any} children;
|
||||
%Candidate mentions an endorsement;
|
||||
%Audience laughs;
|
||||
%Audience boos;
|
||||
%Audience chants;
|
||||
My record shows ...;
|
||||
On my first day in office;
|
||||
In my first hundred days;
|
||||
Clinton says using server was a mistake;
|
||||
Stronger Together;
|
||||
The Middle Class;
|
||||
Deplorables;
|
||||
John McCain;
|
||||
Tim Kaine;
|
||||
Pam Bondi;
|
||||
President Obama;
|
||||
Ronald Reagan;
|
||||
Bernie Sanders;
|
||||
Elizabeth Warren;
|
||||
Mike Pence;
|
||||
Paid family leave;
|
||||
%Shot of Bill Clinton in audience;
|
||||
%Shot of Chelsea Clinton in audience;
|
||||
%Shot of Melania Trump in audience;
|
||||
%Shot of Ivanka Trump in the audience;
|
||||
Free market;
|
||||
Bankruptcy;
|
||||
Taxes;
|
||||
Tax returns;
|
||||
NAFTA;
|
||||
TPP;
|
||||
US budget deficit;
|
||||
Income inequality;
|
||||
Top 1\%;
|
||||
Social Security;
|
||||
Veterans;
|
||||
%Health of candidate;
|
||||
Pneumonia;
|
||||
Trump Foundation;
|
||||
Trump University;
|
||||
Clinton Foundation;
|
||||
The Second Amendment;
|
||||
Black Lives Matter;
|
||||
All Lives Matter;
|
||||
Alt-right;
|
||||
Terrorism;
|
||||
Climate change;
|
||||
Emails;
|
||||
Temperament;
|
||||
Transparency;
|
||||
Any reference to Obama's birthplace;
|
||||
NATO;
|
||||
Trump says he was against the Iraq War;
|
||||
Skittles;
|
||||
``I love \_\_\_\_\_.'';
|
||||
the Supreme Court;
|
||||
DNC hack;
|
||||
%Twitter/Tweet;
|
||||
Immigration reform;
|
||||
Obamacare;
|
||||
Glass Ceiling;
|
||||
Firing the Generals;
|
||||
America is already great.;
|
||||
Muslim ban;
|
||||
Voter ID laws
|
||||
}
|
||||
|
82
checklist1.tex
Normal file
82
checklist1.tex
Normal file
@ -0,0 +1,82 @@
|
||||
% Hopefully a nice table
|
||||
|
||||
$\square$ & Believe me \\[\sep]
|
||||
$\square$ & Make America Great Again \\[\sep]
|
||||
$\square$ & Build a/the wall \\[\sep]
|
||||
$\square$ & Liberal media \\[\sep]
|
||||
$\square$ & What do you have to lose? \\[\sep]
|
||||
$\square$ & I've employed thousands of people \\[\sep]
|
||||
$\square$ & Tremendous success \\[\sep]
|
||||
$\square$ & I can fix it \\[\sep]
|
||||
$\square$ & Political correctness \\[\sep]
|
||||
$\square$ & We don't \emph{win} anymore \\[\sep]
|
||||
$\square$ & Crooked Hillary \\[\sep]
|
||||
$\square$ & Low energy \\[\sep]
|
||||
$\square$ & Rigged \\[\sep]
|
||||
$\square$ & Benghazi \\[\sep]
|
||||
$\square$ & Florida \\[\sep]
|
||||
$\square$ & China \\[\sep]
|
||||
$\square$ & Syria \\[\sep]
|
||||
$\square$ & Israel \\[\sep]
|
||||
$\square$ & Iran \\[\sep]
|
||||
$\square$ & Mexico \\[\sep]
|
||||
$\square$ & Russia \\[\sep]
|
||||
$\square$ & Moderator becomes visibly frustrated \\[\sep]
|
||||
$\square$ & Candidate demands an apology \\[\sep]
|
||||
$\square$ & Heckler interrupts debate \\[\sep]
|
||||
$\square$ & Unqualified \\[\sep]
|
||||
$\square$ & Clinton mentions children--\emph{any} children \\[\sep]
|
||||
$\square$ & My record shows ... \\[\sep]
|
||||
$\square$ & On my first day in office \\[\sep]
|
||||
$\square$ & In my first hundred days \\[\sep]
|
||||
$\square$ & Clinton says using server was a mistake \\[\sep]
|
||||
$\square$ & Stronger Together \\[\sep]
|
||||
$\square$ & The Middle Class \\[\sep]
|
||||
$\square$ & Deplorables \\[\sep]
|
||||
$\square$ & John McCain \\[\sep]
|
||||
$\square$ & Tim Kaine \\[\sep]
|
||||
$\square$ & Pam Bondi \\[\sep]
|
||||
$\square$ & President Obama \\[\sep]
|
||||
$\square$ & Ronald Reagan \\[\sep]
|
||||
$\square$ & Bernie Sanders \\[\sep]
|
||||
$\square$ & Elizabeth Warren \\[\sep]
|
||||
$\square$ & Mike Pence \\[\sep]
|
||||
$\square$ & Paid family leave \\[\sep]
|
||||
$\square$ & Free market \\[\sep]
|
||||
$\square$ & Bankruptcy \\[\sep]
|
||||
$\square$ & Taxes \\[\sep]
|
||||
$\square$ & Tax returns \\[\sep]
|
||||
$\square$ & NAFTA \\[\sep]
|
||||
$\square$ & TPP \\[\sep]
|
||||
$\square$ & US budget deficit \\[\sep]
|
||||
$\square$ & Income inequality \\[\sep]
|
||||
$\square$ & Top 1\% \\[\sep]
|
||||
$\square$ & Social Security \\[\sep]
|
||||
$\square$ & Veterans \\[\sep]
|
||||
$\square$ & Pneumonia \\[\sep]
|
||||
$\square$ & Trump Foundation \\[\sep]
|
||||
$\square$ & Trump University \\[\sep]
|
||||
$\square$ & Clinton Foundation \\[\sep]
|
||||
$\square$ & The Second Amendment \\[\sep]
|
||||
$\square$ & Black Lives Matter \\[\sep]
|
||||
$\square$ & All Lives Matter \\[\sep]
|
||||
$\square$ & Alt-right \\[\sep]
|
||||
$\square$ & Terrorism \\[\sep]
|
||||
$\square$ & Climate change \\[\sep]
|
||||
$\square$ & Emails \\[\sep]
|
||||
$\square$ & Temperament \\[\sep]
|
||||
$\square$ & Transparency \\[\sep]
|
||||
$\square$ & Any reference to Obama's birthplace \\[\sep]
|
||||
$\square$ & NATO \\[\sep]
|
||||
$\square$ & Trump says he was against the Iraq War \\[\sep]
|
||||
$\square$ & Skittles \\[\sep]
|
||||
$\square$ & ``I love \_\_\_\_\_.'' \\[\sep]
|
||||
$\square$ & the Supreme Court \\[\sep]
|
||||
$\square$ & DNC hack \\[\sep]
|
||||
$\square$ & Immigration reform \\[\sep]
|
||||
$\square$ & Obamacare \\[\sep]
|
||||
$\square$ & Glass Ceiling \\[\sep]
|
||||
$\square$ & Firing the Generals \\[\sep]
|
||||
$\square$ & America is already great. \\[\sep]
|
||||
$\square$ & Muslim ban \\[\sep]
|
||||
$\square$ & Voter ID laws \\[\sep]
|
61
makechecklist.py
Normal file
61
makechecklist.py
Normal file
@ -0,0 +1,61 @@
|
||||
#/usr/bin/python
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
|
||||
# makechecklist.py: a quick parser for a specifically-formatted LaTeX file
|
||||
# that produces a nice checklist in {longtable} for the entire list.
|
||||
# The list is, or should be, larger than the number of cells on any one
|
||||
# bingo card, so a canonical list of the cells is useful when evaluating any
|
||||
# one card.
|
||||
#
|
||||
# Jesse Hamner, 2016
|
||||
|
||||
# Functions:
|
||||
|
||||
def makeEntry(varname):
|
||||
"""Take a nicely formatted variable (string) and write it into a LaTeX \
|
||||
[long]table cell"""
|
||||
tabline = str( "$\\square$ & %s \\\\[\\sep]\n" % varname )
|
||||
return(tabline)
|
||||
|
||||
def slurpInFile(fn, theList):
|
||||
"""Open an input file, parse it, ignore some fields, and nicely format the\
|
||||
remainder of the file into a long text string of LaTeX tabular fields."""
|
||||
f=open(fn, 'r')
|
||||
li=f.read()
|
||||
grr = li.split('\n')
|
||||
for i in grr:
|
||||
if( re.search('^%|^\s*$', i) ):
|
||||
continue
|
||||
elif (re.match('\s*}\s*$', i) ):
|
||||
return(theList)
|
||||
else:
|
||||
mline=i.split(';')
|
||||
# print (mline)
|
||||
for j in mline:
|
||||
if ( re.match ('^\s*$', j) ):
|
||||
continue
|
||||
j = re.sub('\\\\myItems{', "", j)
|
||||
theList=theList+makeEntry(j)
|
||||
|
||||
return 0
|
||||
|
||||
# Main loop:
|
||||
|
||||
filename="bingolist.tex"
|
||||
nicetable="% Hopefully a nice table\n\n"
|
||||
nicetable = slurpInFile(filename, nicetable)
|
||||
|
||||
# write out the table to a file:
|
||||
|
||||
ofile="checklist1.tex"
|
||||
output=open(ofile, 'w')
|
||||
output.write(nicetable)
|
||||
output.close()
|
||||
|
||||
# let user know:
|
||||
|
||||
print("wrote output to %s" % ofile)
|
||||
|
||||
# EOF
|
Loading…
x
Reference in New Issue
Block a user