def latex_quote(s):
    """Quote special characters for LaTeX.

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