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')