Created
June 15, 2016 08:53
-
-
Save keiichiw/fcee1822770284064bd01bf3fa9ff185 to your computer and use it in GitHub Desktop.
main.tex内のinputを展開して、一つのall.texをつくる
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
#!/usr/bin/python | |
import shutil | |
shutil.copyfile("./main.tex", "all.tex") | |
flg = True | |
while flg: | |
flg = False | |
out = [] | |
with open("all.tex", "r") as f: | |
lines = f.readlines() | |
for l in lines: | |
l = l.lstrip() | |
if l[0:7] == "\input{": | |
fname = "./" + l.rstrip()[7:-1] + ".tex" | |
with open(fname, "r") as g: | |
out += g.readlines() | |
out.append("\n") | |
flg = True | |
else: | |
out.append(l) | |
with open("all.tex", "w") as f: | |
for l in out: | |
f.write(l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
latexpand
を使おう