- Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathsplit.py
More file actions
Latest commit
30 lines (27 loc) · 764 Bytes
/
Copy pathsplit.py
File metadata and controls
30 lines (27 loc) · 764 Bytes
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
"""Outputs the LaTeX source for a single chapter."""
importsys
defmain(tex, num):
src=open(tex)
# copy the preamble
forlineinsrc:
printline,
ifline.startswith("\\begin{document}"):
print"\\setcounter{chapter}{"+str(num-1) +"}\n"
break
# copy the chapter
i=-1
forlineinsrc:
ifline.startswith("\\backmatter"):
break
ifline.startswith("\\chapter"):
i+=1
ifi>num:
break
ifi==num:
printline,
print"\\end{document}"
if__name__=="__main__":
iflen(sys.argv) ==3:
main(sys.argv[1], int(sys.argv[2]))
else:
print"Usage: python split.py MAIN.tex NUMBER"