def escape_latex(text):
text = unicode(text.decode('<STR_LIT:utf-8>'))<EOL>CHARS = {<EOL>'<STR_LIT:&>': r'<STR_LIT>',<EOL>'<STR_LIT:%>': r'<STR_LIT>',<EOL>'<STR_LIT:$>': r'<STR_LIT>',<EOL>'<STR_LIT:#>': r'<STR_LIT>',<EOL>'<STR_LIT:_>': r'<STR_LIT>',<EOL>'<STR_LIT:{>': r'<STR_LIT>',<EOL>'<STR_LIT:}>': r'<STR_LIT>',<EOL>'<STR_LIT>': r'<STR_LIT>',<EOL>'<STR_LIT>': r'<STR_LIT>',<EOL>'<STR_LIT:\\>': r'<STR_LIT>',<EOL>}<EOL>escaped = "<STR_LIT>".join([CHARS.get(char, char) for char in text])<EOL>return escaped.encode('<STR_LIT:utf-8>')<EOL>
r"""Escape characters of given text.

    This function takes the given text and escapes characters
    that have a special meaning in LaTeX: # $ % ^ & _ { } ~ \