Skip to content

Instantly share code, notes, and snippets.

@anglyan
Created May 27, 2016 03:44
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 anglyan/ac8511d49623b894c224d2605d296df2 to your computer and use it in GitHub Desktop.
Save anglyan/ac8511d49623b894c224d2605d296df2 to your computer and use it in GitHub Desktop.
python + beamer: reads a list of files and descriptions and compiles a latex presentation using beamer. Details at: http://www.ayanguasgil.net/python/beamer.html
import csv
header = r"""
\documentclass[mathserif]{beamer}
\usetheme{default}
\begin{document}
"""
footer = r"""
\end{document}
"""
baseslide = r"""
\begin{frame}
\frametitle{%(title)s}
%(content)s
\begin{center}
\includegraphics[width=0.8\textwidth]{%(filename)s}
\end{center}
\end{frame}
"""
def parse_csv(filename):
data = [row for row in csv.reader(open(filename, 'rU'))]
slides = [create_slide(*row) for row in data]
return slides
def create_slide(filename, title, content):
slide = {}
slide['filename'] = filename
slide['content'] = content
slide['title'] = title
return (baseslide % slide)
if __name__ == '__main__':
import sys
print header + "".join(parse_csv(sys.argv[1])) + footer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment