(string)
return string.encode('ascii')
In addition to converting all unicode characters to LaTeX expressions
    this function also replaces some characters like newlines with their LaTeX
    equvivalent.
In addition to converting all unicode characters to LaTeX expressions
    this function also replaces some characters like newlines with their LaTeX
    equvivalent.
In addition to converting all unicode characters to LaTeX expressions this function also replaces some characters like newlines with their LaTeX equvivalent .
def raw_unicode_to_latex(string):
    """In addition to converting all unicode characters to LaTeX expressions
    this function also replaces some characters like newlines with their LaTeX
    equvivalent."""

    # We need to quote any special character (or replace it)
    for char, replacement in ascii_to_latex:
        string = string.replace(char, replacement)

    string = unicode_to_latex(string)

    string = str(string)

    # Replace many newlines with a paragraph marker
    string, count = re.subn('\n\n+', '\u2029', string, flags=re.MULTILINE)

    # Replace single newline with \\+newline
    string = string.replace('\n', '\\\\\n')

    # And remove the paragraph marker again (insert two newlines)
    string = string.replace('\u2029', '\n\n')

    return string.encode('ascii')
def raw_unicode_to_latex ( string ) : # We need to quote any special character (or replace it) for char , replacement in ascii_to_latex : string = string . replace ( char , replacement ) string = unicode_to_latex ( string ) string = str ( string ) # Replace many newlines with a paragraph marker string , count = re . subn ( '\n\n+' , '\u2029' , string , flags = re . MULTILINE ) # Replace single newline with \\+newline string = string . replace ( '\n' , '\\\\\n' ) # And remove the paragraph marker again (insert two newlines) string = string . replace ( '\u2029' , '\n\n' ) return string . encode ( 'ascii' )