Skip to content

Instantly share code, notes, and snippets.

@ram1123
Created February 18, 2023 14:56
Show Gist options
  • Save ram1123/452cf3b68e60c4698f1636feb9b15483 to your computer and use it in GitHub Desktop.
Save ram1123/452cf3b68e60c4698f1636feb9b15483 to your computer and use it in GitHub Desktop.
import os
# Specify the directory containing the PDF files
pdf_dir = '/afs/cern.ch/user/r/rasharma/work/LearnCombine/CMSSW_11_3_4/src/2l2Q_limitSettingTool/ImpactPlotCollection/'
# Get a list of the PDF files in the directory
pdf_files = [f for f in os.listdir(pdf_dir) if f.endswith('.pdf')]
# Create a LaTeX file for the presentation
with open('presentation.tex', 'w') as f:
f.write('\\documentclass{beamer}\n')
f.write('\\usepackage{graphicx}\n')
f.write('\\begin{document}\n')
# Loop over the PDF files and create a slide for each one
for pdf_file in pdf_files:
# Add a slide to the presentation with the PDF file and slide title
slide_title = pdf_file.replace('.pdf', '').replace('_', ' ')
f.write('\\begin{frame}\n')
f.write('\\frametitle{%s}\n' % slide_title)
f.write('\\includegraphics[width=\\textwidth]{%s}\n' % os.path.join(pdf_dir, pdf_file))
f.write('\\end{frame}\n')
f.write('\\end{document}\n')
# Compile the LaTeX file to create the PDF presentation
os.system('pdflatex presentation.tex')
os.system('rm -f *.tex *.out *.snm *.aux *.nav *.toc *.log')
@ram1123
Copy link
Author

ram1123 commented Feb 18, 2023

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