def latex_table(result, *, decimal_places=3, label=None):
    """
    Creates a latex table from the results dataframe of the statistical analysis.

    # Parameters

    result (RankResult):
        Should be the return value the autorank function.

    decimal_places (int, default=3):
        Number of decimal places that are used for the report.

    label (str, default=None):
        Label of the table. Defaults to 'tbl:stat_results' if None.
    """
    if label is None:
        label = 'tbl:stat_results'
    table_df = result.rankdf
    columns = table_df.columns.to_list()
    if result.pvalue >= result.alpha:
        columns.remove('effect_size')
        columns.remove('magnitude')
    if result.posthoc == 'tukeyhsd':
        columns.remove('meanrank')
    columns.insert(columns.index('ci_lower'), 'CI')
    columns.remove('ci_lower')
    columns.remove('ci_upper')
    rename_map = {}
    if result.all_normal:
        rename_map['effect_size'] = '$d$'
    else:
        rename_map['effect_size'] = 'D-E-L-T-A'
    rename_map['magnitude'] = 'Magnitude'
    rename_map['mad'] = 'MAD'
    rename_map['median'] = 'MED'
    rename_map['meanrank'] = 'MR'
    rename_map['mean'] = 'M'
    rename_map['std'] = 'SD'
    format_string = '[{0[ci_lower]:.' + str(decimal_places
        ) + 'f}, {0[ci_upper]:.' + str(decimal_places) + 'f}]'
    table_df['CI'] = table_df.agg(format_string.format, axis=1)
    table_df = table_df[columns]
    table_df = table_df.rename(rename_map, axis='columns')
    float_format = '{:0.' + str(decimal_places) + 'f}'
    table_string = table_df.to_latex(float_format=float_format.format).strip()
    table_string = table_string.replace('D-E-L-T-A', '$\\delta$')
    print('\\begin{table}[h]')
    print('\\centering')
    print(table_string)
    print('\\caption{Summary of populations}')
    print('\\label{%s}' % label)
    print('\\end{table}')
