Generate a pdf report with plots using latex.

def run_latex_report(base, report_dir, section_info):
    """Generate a pdf report with plots using latex.
    """
    out_name = "%s_recal_plots.tex" % base
    out = os.path.join(report_dir, out_name)
    with open(out, "w") as out_handle:
        out_tmpl = Template(out_template)
        out_handle.write(out_tmpl.render(sections=section_info))
    start_dir = os.getcwd()
    try:
        os.chdir(report_dir)
        cl = ["pdflatex", out_name]
        child = subprocess.Popen(cl)
        child.wait()
    finally:
        os.chdir(start_dir)