code: def latex_quote(s):
      
      special = {'_':r'\_', '$':r'\$', '#':r'\#'}
      s = str(s)
      for char,repl in special.items():
          new = s.replace(char, repl)
          s = new[:]
      return s
docs: Quote special characters for LaTeX.
  
      (Incomplete, currently only deals with underscores, dollar and hash.)