Skip to content

Instantly share code, notes, and snippets.

@keiichiw
Created June 15, 2016 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keiichiw/fcee1822770284064bd01bf3fa9ff185 to your computer and use it in GitHub Desktop.
Save keiichiw/fcee1822770284064bd01bf3fa9ff185 to your computer and use it in GitHub Desktop.
main.tex内のinputを展開して、一つのall.texをつくる
#!/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)
@keiichiw
Copy link
Author

latexpand を使おう

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment