def format_colname(name):
    """
    Convert the column name to a better formatted name
    """
    cmcol = " [cm$^{-2}$]"
    mag = " [mag]"
    col_mag = " [cm$^{-2}$ mag$^{-1}$]"

    dic_pairs = {
        "AV": "$A(V)$" + mag,
        "RV": "$R(V)$",
        "EBV": "$E(B-V)$" + mag,
        "CAV1": "$C^{A(V)}_1$",
        "CAV2": "$C^{A(V)}_2$",
        "CAV3": "$C^{A(V)}_3$",
        "CAV4": "$C^{A(V)}_4$",
        "C1": "$C_1$",
        "C2": "$C_2$",
        "C3": "$C_3$",
        "C4": "$C_4$",
        "x_o": "$x_o$",
        "gamma": r"$\gamma$",
        "bump_area": r"$\pi C^{A(V)}_3 / 2 \gamma$",
        "bump_amp": r"$C^{A(V)}_3 / 2 \gamma^2$",
        "fh2": "$f(\mathrm{H}_2)$",
        "nhtot": "$N(\mathrm{H})$" + cmcol,
        "nh2": "$N(\mathrm{H}_2)$" + cmcol,
        "nhi": "$N(HI)$" + cmcol,
        "NH_AV": "$N(\mathrm{H})/A(V)$" + col_mag,
        "NH_EBV": "$N(\mathrm{H})/E(B-V)$" + col_mag,
        "1_RV": "$1/R(V)$",
        "A1000": "$A(1000)$" + mag,
        "A1000_AV": "$A(1000)/A(V)$",
        "A2175": "$A(2175)$" + mag,
        "A2175_AV": "$A(2175)/A(V)$",
        "T01": "$T_{01}$ [K]",
        "denhtot": "$n(\mathrm{H})$ [cm$^{-3}$]",
    }

    out_name = name
    if name[:3] == "log":
        out_name = r"$\log (" + name[3:].upper() + ")$"
    elif name in dic_pairs.keys():
        out_name = dic_pairs[name]

    return out_name