Created
February 6, 2017 09:54
-
-
Save wuyongzheng/256c77b3b35dbdc11dcd436fa4599bf2 to your computer and use it in GitHub Desktop.
Generate math cards for kids
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gendpage (cards, linesPerPage): | |
nitem = linesPerPage*2; | |
if len(cards) < nitem: | |
co = cards + [("", "", "")]*(nitem-len(cards)) | |
cards = [] | |
else: | |
co = cards[0:nitem] | |
cards = cards[nitem:] | |
for i in range(0, linesPerPage): | |
print("\\vspace*{\\fill}") | |
print("\\noindent") | |
print("\\begin{tabularx}{\\textwidth}{XcXXcX}") | |
print("& \underline{\\fontsize{3.4cm}{3.7cm}\selectfont " + co[i*2+0][0] + "} & &") | |
print("& \underline{\\fontsize{3.4cm}{3.7cm}\selectfont " + co[i*2+1][0] + "} & \\\\") | |
print("\end{tabularx}") | |
print("\\vspace*{\\fill}") | |
print("") | |
print("\pagebreak") | |
for i in range(0, linesPerPage): | |
print("\\vspace*{\\fill}") | |
print("\\noindent") | |
print("\\begin{tabularx}{\\textwidth}{XcXXcX}") | |
print("& \\textcolor{gray}{\underline{\\fontsize{3.4cm}{3.7cm}\selectfont " + co[i*2+1][1] + "}} & &") | |
print("& \\textcolor{gray}{\underline{\\fontsize{3.4cm}{3.7cm}\selectfont " + co[i*2+0][1] + "}} & \\\\") | |
print("\end{tabularx}") | |
print("\\vspace*{\\fill}") | |
print("") | |
print("\pagebreak") | |
return cards | |
def main (): | |
cards = [(str(x) + "+" + str(y), str(x+y)) for x in range(0, 10) for y in range(0, 10)] | |
print("\documentclass{report}") | |
print("\usepackage[margin=0in, a4paper]{geometry}") | |
print("\usepackage{tabularx}") | |
print("\usepackage{anyfontsize}") | |
print("\usepackage{xcolor}") | |
print("\pagestyle{empty}") | |
print("\\begin{document}") | |
while (cards): | |
cards = gendpage(cards, 5) | |
print("\\end{document}") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment