-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
195 lines (176 loc) · 6.34 KB
/
main.py
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
"""Redundant script to test printing book"""
# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
def print_book():
"""Print a book"""
thisfile = open("splayout.tex", 'w',encoding='utf-8')
print_preamble(thisfile)
print_begin(thisfile)
land1 = 'landscape.jpg'
land2 = 'landscape.jpg'
port1 = 'portrait.jpg'
port2 = 'portrait.jpg'
port3 = 'portrait.jpg'
port4 = 'portrait.jpg'
capt_l1 = 'CAPTION L1'
capt_l2 = 'CAPTION L2'
capt_p1 = 'CAPTION P1'
capt_p2 = 'CAPTION P2'
capt_p3 = 'CAPTION P3'
capt_p4 = 'CAPTION P4'
print_ll(thisfile,land1,land2,capt_l1,capt_l2)
print_l(thisfile,land1,capt_l1)
print_pppp(thisfile,port1,port2,port3,port4,capt_p1,capt_p2,capt_p3,capt_p4)
print_ppp(thisfile,port1,port2,port3,capt_p1,capt_p2,capt_p3)
print_pp(thisfile,port1,port2,capt_p1,capt_p2)
print_p(thisfile,port1,capt_p1)
print_ppl(thisfile,port1,port2,land1,capt_p1,capt_p2,capt_l1)
print_lpp(thisfile,land1,port1,port2,capt_l1,capt_p1,capt_p2)
print_pl(thisfile,port1,land1,capt_p1,capt_l1)
print_lp(thisfile,land1,port1,capt_l1,capt_p1)
print_end(thisfile)
thisfile.close()
def print_preamble(thisfile):
"""Print .tex file preamble"""
thisfile.write('\\documentclass[10pt,letterpaper]{article}\n')
thisfile.write('\\usepackage[top=1in, bottom=1in, left=0.5in, right=0.5in, paperwidth=8.5in, paperheight=11in]{geometry}\n')
thisfile.write("\\usepackage{amsfonts,amssymb,amsmath}\n")
thisfile.write("\\usepackage{graphicx}\n")
thisfile.write("\\usepackage{float}\n")
thisfile.write("\\setlength{\\parindent}{0pt}")
def print_begin(thisfile):
"""Print the begin statement"""
thisfile.write('\\begin{document}\n')
def print_end(thisfile):
"""Print the end statement"""
thisfile.write('\\end{document}\n')
def print_landscape_line(thisfile,filename):
"""Print a landscape line"""
thisfile.write('\\includegraphics[width=5.19in]{landscape.jpg}\n')
def print_portrait_line(thisfile,filename):
"""Print a portrait line"""
thisfile.write('\\includegraphics[height=4in]{portrait.jpg}\n')
def print_caption_line(thisfile,text):
"""Print a caption line"""
thisfile.write(text +'\\\\\n')
def print_ll(thisfile,land1,land2,capt_l1,capt_l2):
"""Print LL layout"""
thisfile.write('\n')
thisfile.write('% Layout LL\n')
print_landscape_line(thisfile, land1)
thisfile.write('\n')
thisfile.write('\\vspace{0.25in}\n')
print_landscape_line(thisfile, land2)
thisfile.write('\n')
print_caption_line(thisfile, capt_l1)
print_caption_line(thisfile, capt_l2)
thisfile.write('\\pagebreak\n')
def print_l(thisfile,land1,capt_l1):
"""Print L layout"""
thisfile.write('\n')
thisfile.write('% Layout L\n')
print_landscape_line(thisfile, land1)
thisfile.write('\n')
print_caption_line(thisfile, capt_l1)
thisfile.write('\\pagebreak\n')
def print_pppp(thisfile,port1,port2,port3,port4,capt_p1,capt_p2,capt_p3,capt_p4):
"""Print PPPP layout"""
thisfile.write('\n')
thisfile.write('% Layout PPPP\n')
print_portrait_line(thisfile, port1)
print_portrait_line(thisfile, port2)
thisfile.write('\n')
print_portrait_line(thisfile, port3)
print_portrait_line(thisfile, port4)
thisfile.write('\n')
print_caption_line(thisfile, capt_p1)
print_caption_line(thisfile, capt_p2)
print_caption_line(thisfile, capt_p3)
print_caption_line(thisfile, capt_p4)
thisfile.write('\\pagebreak\n')
def print_ppp(thisfile,port1,port2,port3,capt_p1,capt_p2,capt_p3):
"""Print PPP layout"""
thisfile.write('\n')
thisfile.write('% Layout PPP\n')
print_portrait_line(thisfile, port1)
print_portrait_line(thisfile, port2)
thisfile.write('\n')
print_portrait_line(thisfile, port3)
thisfile.write('\n')
print_caption_line(thisfile, capt_p1)
print_caption_line(thisfile, capt_p2)
print_caption_line(thisfile, capt_p3)
thisfile.write('\\pagebreak\n')
def print_pp(thisfile,port1,port2,capt_p1,capt_p2):
"""Print PP layout"""
thisfile.write('\n')
thisfile.write('% Layout PP\n')
print_portrait_line(thisfile, port1)
print_portrait_line(thisfile, port2)
thisfile.write('\n')
print_caption_line(thisfile, capt_p1)
print_caption_line(thisfile, capt_p2)
thisfile.write('\\pagebreak\n')
def print_p(thisfile,port1,capt_p1):
"""Print P layout"""
thisfile.write('\n')
thisfile.write('% Layout P\n')
print_portrait_line(thisfile, port1)
thisfile.write('\n')
print_caption_line(thisfile, capt_p1)
thisfile.write('\\pagebreak\n')
def print_ppl(thisfile,port1,port2,land1,capt_p1,capt_p2,capt_l1):
"""Print PPL layout"""
thisfile.write('\n')
thisfile.write('% Layout PPL\n')
print_portrait_line(thisfile, port1)
print_portrait_line(thisfile, port2)
thisfile.write('\n')
thisfile.write('\\vspace{0.25in}\n')
print_landscape_line(thisfile, land1)
thisfile.write('\n')
print_caption_line(thisfile, capt_p1)
print_caption_line(thisfile, capt_p2)
print_caption_line(thisfile, capt_l1)
thisfile.write('\\pagebreak\n')
def print_lpp(thisfile,land1,port1,port2,capt_l1,capt_p1,capt_p2):
"""Print LPP layout"""
thisfile.write('\n')
thisfile.write('% Layout LPP\n')
print_landscape_line(thisfile, land1)
thisfile.write('\n')
thisfile.write('\\vspace{0.25in}\n')
print_portrait_line(thisfile, port1)
print_portrait_line(thisfile, port2)
thisfile.write('\n')
print_caption_line(thisfile, capt_l1)
print_caption_line(thisfile, capt_p1)
print_caption_line(thisfile, capt_p2)
thisfile.write('\\pagebreak\n')
def print_pl(thisfile,port1,land1,capt_p1,capt_l1):
"""Print PL layout"""
thisfile.write('\n')
thisfile.write('% Layout PL\n')
print_portrait_line(thisfile, port1)
thisfile.write('\n')
thisfile.write('\\vspace{0.25in}\n')
print_landscape_line(thisfile, land1)
thisfile.write('\n')
print_caption_line(thisfile, capt_p1)
print_caption_line(thisfile, capt_l1)
thisfile.write('\\pagebreak\n')
def print_lp(thisfile,land1,port1,capt_l1,capt_p1):
"""Print LP layout"""
thisfile.write('\n')
thisfile.write('% Layout LP\n')
print_landscape_line(thisfile, land1)
thisfile.write('\n')
thisfile.write('\\vspace{0.25in}\n')
print_portrait_line(thisfile, port1)
thisfile.write('\n')
print_caption_line(thisfile, capt_l1)
print_caption_line(thisfile, capt_p1)
thisfile.write('\\pagebreak\n')
if __name__ == '__main__':
print_book()