def typeset_latex_math(variable) -> str:
    """
    Returns `variable` as a string with LaTeX math typesetting.

    Args:
        variable: The python variable to be saved.

    Returns:
        str: String accoring to LaTeX typesetting.

    """
    has_unit = hasattr(variable, 'u')
    if has_unit:
        if str(variable.u) == 'dimensionless':
            suffix = None
        else:
            suffix = r'\,' + '{:Lx}'.format(variable.u)
        value = variable.magnitude
    else:
        suffix = None
        value = variable
    has_error = hasattr(value, 'std_dev')
    if has_error:
        payload = '{:L}'.format(value)
    else:
        payload = str(value)
    if suffix is not None:
        if has_error:
            payload = '({}){}'.format(payload, suffix)
        else:
            payload += suffix
    return payload