def latex_command(value, num, mapping):
    """
    Helper function to generate a color name and definition for a given value.
    Num is used to identify different colors. Mapping is the mapping generated in
    generate_table
    """
    r,g,b,a = mapping.to_rgba(value)
    colorname = 'color' + str(num)
    definition = "\definecolor{{{colorname}}}{{rgb}}{{{r},{g},{b}}}".format(colorname = colorname,
                                                                            r = r,
                                                                            g = g,
                                                                            b = b)
    return colorname, definition