def tex2pdf(tex_file, output_file=None, output_format='<STR_LIT>'):
if not os.path.exists(tex_file):<EOL><INDENT>raise IOError('<STR_LIT>'.format(tex_file))<EOL><DEDENT>if output_format != '<STR_LIT>' and output_format != '<STR_LIT>':<EOL><INDENT>raise ValueError("<STR_LIT>".format(output_format))<EOL><DEDENT>cmd_name = '<STR_LIT>'<EOL>check_command(cmd_name)<EOL>args_strings = [cmd_name]<EOL>if output_file is not None:<EOL><INDENT>args_strings += ['<STR_LIT>'.format(os.path.abspath(os.path.dirname(output_file)))]<EOL><DEDENT>result_dir = os.path.dirname(output_file) if output_file else os.path.dirname(tex_file)<EOL>args_strings += ['<STR_LIT>'.format(output_format)]<EOL>args_strings += ['<STR_LIT:">' + tex_file + '<STR_LIT:">']<EOL>log.debug('<STR_LIT>'.format(cmd_name, args_strings))<EOL>ret = simple_call(args_strings)<EOL>result_file = os.path.join(result_dir, remove_ext(os.path.basename(tex_file)) + '<STR_LIT:.>' + output_format)<EOL>if os.path.exists(result_file):<EOL><INDENT>shutil.move(result_file, output_file)<EOL><DEDENT>else:<EOL><INDENT>raise IOError('<STR_LIT>')<EOL><DEDENT>log.debug('<STR_LIT>'.format(result_dir))<EOL>cleanup(result_dir, '<STR_LIT>')<EOL>cleanup(result_dir, '<STR_LIT>')<EOL>return ret<EOL>
Call PDFLatex to convert TeX files to PDF.

    Parameters
    ----------
    tex_file: str
        Path to the input LateX file.

    output_file: str
        Path to the output PDF file.
        If None, will use the same output directory as the tex_file.

    output_format: str
        Output file format. Choices: 'pdf' or 'dvi'. Default: 'pdf'

    Returns
    -------
    return_value
        PDFLatex command call return value.