def float_to_latex(x, format="<STR_LIT>"):  <EOL>
if x == <NUM_LIT:0.>:<EOL><INDENT>return '<STR_LIT:0>'<EOL><DEDENT>base_str = format % x<EOL>if "<STR_LIT:e>" not in base_str:<EOL><INDENT>return base_str<EOL><DEDENT>mantissa, exponent = base_str.split("<STR_LIT:e>")<EOL>if float(mantissa).is_integer():<EOL><INDENT>mantissa = int(float(mantissa))<EOL><DEDENT>exponent = exponent.lstrip("<STR_LIT>")<EOL>if exponent.startswith('<STR_LIT>'):<EOL><INDENT>exponent = '<STR_LIT:->' + exponent[<NUM_LIT:2>:]<EOL><DEDENT>if float(mantissa) == <NUM_LIT:1.0>:<EOL><INDENT>return r"<STR_LIT>" % exponent<EOL><DEDENT>return r"<STR_LIT>" % (mantissa, exponent)<EOL>
r"""Convert a floating point number to a latex representation.

    In particular, scientific notation is handled gracefully: e -> 10^

    Parameters
    ----------
    x : `float`
        the number to represent

    format : `str`, optional
        the output string format

    Returns
    -------
    tex : `str`
        a TeX representation of the input

    Examples
    --------
    >>> from gwpy.plot.tex import float_to_latex
    >>> float_to_latex(1)
    '1'
    >>> float_to_latex(2000)
    '2\times 10^{3}'
    >>> float_to_latex(100)
    '10^{2}'
    >>> float_to_latex(-500)
    r'-5\!\!\times\!\!10^{2}'