def latex_preview(math_expr, variables=(), functions=(), case_sensitive=False):
 if (math_expr.strip() == ''):
  return ''
 latex_interpreter = ParseAugmenter(math_expr, case_sensitive)
 latex_interpreter.parse_algebra()
 (variables, functions) = add_defaults(variables, functions, case_sensitive)
 if case_sensitive:
  casify = (lambda x: x)
 else:
  casify = (lambda x: x.lower())
 render_actions = {'number': render_number, 'variable': variable_closure(variables, casify), 'function': function_closure(functions, casify), 'atom': render_atom, 'power': render_power, 'parallel': render_parallel, 'product': render_product, 'sum': render_sum}
 backslash = '\\'
 wrap_escaped_strings = (lambda s: LatexRendered(s.replace(backslash, (backslash * 2))))
 output = latex_interpreter.reduce_tree(render_actions, terminal_converter=wrap_escaped_strings)
 return output.latex

def latex_preview ( math_expr , variables = ( ) , functions = ( ) , case_sensitive = False ) : if ( math_expr . strip ( ) == '' ) : return '' latex_interpreter = ParseAugmenter ( math_expr , case_sensitive ) latex_interpreter . parse_algebra ( ) ( variables , functions ) = add_defaults ( variables , functions , case_sensitive ) if case_sensitive : casify = ( lambda x : x ) else : casify = ( lambda x : x . lower ( ) ) render_actions = { 'number' : render_number , 'variable' : variable_closure ( variables , casify ) , 'function' : function_closure ( functions , casify ) , 'atom' : render_atom , 'power' : render_power , 'parallel' : render_parallel , 'product' : render_product , 'sum' : render_sum } backslash = '\\' wrap_escaped_strings = ( lambda s : LatexRendered ( s . replace ( backslash , ( backslash * 2 ) ) ) ) output = latex_interpreter . reduce_tree ( render_actions , terminal_converter = wrap_escaped_strings ) return output . latex
convert math_expr into latex .