Created
May 27, 2016 03:44
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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