r"""
    Args:
        _cmdname (?):

    Returns:
        ?: command_name

    CommandLine:
        python -m utool.util_latex --exec-latex_sanitize_command_name

    Example:
        >>> # DISABLE_DOCTEST
        >>> from utool.util_latex import *  # NOQA
        >>> _cmdname = '#foo bar.'
        >>> command_name = latex_sanitize_command_name(_cmdname)
        >>> result = ('command_name = %s' % (str(command_name),))
        >>> print(result)
        FooBar

def latex_sanitize_command_name(_cmdname):
    r"""
    Args:
        _cmdname (?):

    Returns:
        ?: command_name

    CommandLine:
        python -m utool.util_latex --exec-latex_sanitize_command_name

    Example:
        >>> # DISABLE_DOCTEST
        >>> from utool.util_latex import *  # NOQA
        >>> _cmdname = '#foo bar.'
        >>> command_name = latex_sanitize_command_name(_cmdname)
        >>> result = ('command_name = %s' % (str(command_name),))
        >>> print(result)
        FooBar
    """
    import utool as ut
    command_name = _cmdname
    try:
        def subroman(match):
            import roman
            try:
                groupdict = match.groupdict()
                num = int(groupdict['num'])
                if num == 0:
                    return ''
                return roman.toRoman(num)
            except Exception as ex:
                ut.printex(ex, keys=['groupdict'])
                raise
        command_name = re.sub(ut.named_field('num', r'\d+'), subroman, command_name)
    except ImportError as ex:
        if ut.SUPER_STRICT:
            ut.printex(ex)
            raise
    # remove numbers
    command_name = re.sub(r'[\d' + re.escape('#()[]{}.') + ']', '', command_name)
    # Remove _ for camel case
    #def to_camel_case(str_list):
    #    # hacky
    #    return ''.join([str_ if len(str_) < 1 else str_[0].upper() + str_[1:] for str_ in str_list])
    #command_name = to_cammel_case(re.split('[_ ]', command_name)[::2])
    str_list = re.split('[_ ]', command_name)
    #command_name = to_cammel_case(str_list)
    command_name = ut.to_camel_case('_'.join(str_list), mixed=True)
    return command_name