Skip to content
Snippets Groups Projects
Commit 826b619c authored by Nicolas Barthes's avatar Nicolas Barthes
Browse files

added LaTEX template and function for PDF report

parent 6dec0081
No related branches found
No related tags found
No related merge requests found
......@@ -184,31 +184,35 @@ def report(*argv):
\bibliography{refs.bib}
\clearpage
\end{document}"""
return latex_report
# export the .tex file in the Report folder
filename = r'report.tex'
with open(filename, 'w') as latex_file:
latex_file.write(latex_report)
# create the Tex file - sections in args will be displayed: {'sample':'Sample Selection';'model':'Model Creation';'predict':'Predictions';'help':'LaTEX help for figs and tables';}
latex_report = report('sample', 'predict',)
# export the .tex file in the Report folder
filename = r'report.tex'
with open(filename, 'w') as latex_file:
latex_file.write(latex_report)
# run pdflatex with bibtex compilation (2nd run)
proc = subprocess.Popen([r'C:\Donnees\Logiciels\Papps\PortableApps\Notepad++Portable\LaTEX\texmfs\install\miktex\bin\pdflatex.exe', filename])
proc.communicate()
proc = subprocess.Popen([r'C:\Donnees\Logiciels\Papps\PortableApps\Notepad++Portable\LaTEX\texmfs\install\miktex\bin\bibtex.exe', filename[:-4]])
proc.communicate()
proc = subprocess.Popen([r'C:\Donnees\Logiciels\Papps\PortableApps\Notepad++Portable\LaTEX\texmfs\install\miktex\bin\pdflatex.exe', filename])
proc.communicate()
proc = subprocess.Popen([r'C:\Donnees\Logiciels\Papps\PortableApps\Notepad++Portable\LaTEX\texmfs\install\miktex\bin\pdflatex.exe', filename])
proc.communicate()
# remove pdflatex compilation files
os.unlink(filename[:-4] + '.log')
os.unlink(filename[:-4] + '.aux')
os.unlink(filename[:-4] + '.bbl')
os.unlink(filename[:-4] + '.blg')
os.unlink(filename[:-4] + '.out')
# open the report
proc = subprocess.Popen([filename[:-4] + '.pdf'], shell=True)
proc.communicate()
\ No newline at end of file
def compile_latex():
# path to pdflatex
pdflatex = "C:/Donnees/Logiciels/Papps/PortableApps/Notepad++Portable/LaTEX/texmfs/install/miktex/bin/"
filename = 'report.tex'
# run pdflatex with bibtex compilation (2nd run)
proc = subprocess.Popen([pdflatex + 'pdflatex.exe', filename])
proc.communicate()
proc = subprocess.Popen([r'C:\Donnees\Logiciels\Papps\PortableApps\Notepad++Portable\LaTEX\texmfs\install\miktex\bin\bibtex.exe', filename[:-4]])
proc.communicate()
proc = subprocess.Popen([r'C:\Donnees\Logiciels\Papps\PortableApps\Notepad++Portable\LaTEX\texmfs\install\miktex\bin\pdflatex.exe', filename])
proc.communicate()
proc = subprocess.Popen([r'C:\Donnees\Logiciels\Papps\PortableApps\Notepad++Portable\LaTEX\texmfs\install\miktex\bin\pdflatex.exe', filename])
proc.communicate()
# remove pdflatex compilation files
os.unlink(filename[:-4] + '.log')
os.unlink(filename[:-4] + '.aux')
os.unlink(filename[:-4] + '.bbl')
os.unlink(filename[:-4] + '.blg')
os.unlink(filename[:-4] + '.out')
# open the report
proc = subprocess.Popen([filename[:-4] + '.pdf'], shell=True)
proc.communicate()
compile_latex()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment