import re


def escape_LaTeX(s):
  """returns s with LaTeX active characters replaced.

  I also take the liberty of improving quotes when I can get them.
  """
  return re.sub('"([^"]+)"', r"``\1''",
    s.replace( "\\" , "$\\backslash$" 
    ).replace("}" , "\\}" 
    ).replace("{" , "\\{" 
    ).replace("&" , "\\&" 
    ).replace("#" , "\\#" 
    ).replace("%" , "\\%" 
    ).replace("_" , "\\_"))