forked from wiso/ListOfPublicationsFromInspireHEP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_latex.py
executable file
·34 lines (26 loc) · 1.19 KB
/
create_latex.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
#!/usr/bin/env python
import subprocess
import argparse
parser = argparse.ArgumentParser(description='Create pdf with bibliography',
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog='example: create_latex bibtex_2016-02-07.bib')
parser.add_argument('bibtex')
parser.add_argument('--title', default='List of publications', help='Title of the document')
parser.add_argument('--author', default=None, help='Author of the document')
args = parser.parse_args()
TEMPLATE_FILENAME = "template_latex.tex"
with open(TEMPLATE_FILENAME) as f:
template = f.read()
template = template.replace("ADD_BIBTEX_HERE", args.bibtex)
template = template.replace("ADD_TITLE_HERE", args.title)
if args.author:
template = template.replace("ADD_AUTHOR_HERE", args.author)
else:
template = template.replace("\\author{ADD_AUTHOR_HERE}", "")
with open('publications.tex', 'w') as f:
f.write(template)
subprocess.call(['pdflatex', 'publications.tex'])
subprocess.call(['bibtex', 'publications.aux'])
subprocess.call(['pdflatex', 'publications.tex'])
subprocess.call(['pdflatex', 'publications.tex'])
print("output written in publications.pdf")