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