def genelatex(body, wrap):
 lt = LaTeXTool.instance()
 breqn = (wrap and lt.use_breqn and kpsewhich('breqn.sty'))
 (yield u('\\documentclass{article}'))
 packages = lt.packages
 if breqn:
  packages = (packages + ['breqn'])
 for pack in packages:
  (yield u('\\usepackage{{{0}}}'.format(pack)))
 (yield u('\\pagestyle{empty}'))
 if lt.preamble:
  (yield lt.preamble)
 (yield u('\\begin{document}'))
 if breqn:
  (yield u('\\begin{dmath*}'))
  (yield body)
  (yield u('\\end{dmath*}'))
 elif wrap:
  (yield u'$${0}$$'.format(body))
 else:
  (yield body)
 (yield u'\\end{document}')

def genelatex ( body , wrap ) : lt = LaTeXTool . instance ( ) breqn = ( wrap and lt . use_breqn and kpsewhich ( 'breqn.sty' ) ) ( yield u ( '\\documentclass{article}' ) ) packages = lt . packages if breqn : packages = ( packages + [ 'breqn' ] ) for pack in packages : ( yield u ( '\\usepackage{{{0}}}' . format ( pack ) ) ) ( yield u ( '\\pagestyle{empty}' ) ) if lt . preamble : ( yield lt . preamble ) ( yield u ( '\\begin{document}' ) ) if breqn : ( yield u ( '\\begin{dmath*}' ) ) ( yield body ) ( yield u ( '\\end{dmath*}' ) ) elif wrap : ( yield u'$${0}$$' . format ( body ) ) else : ( yield body ) ( yield u'\\end{document}' )
generate latex document for dvipng backend .