def tabular_tex(
    body_df,
    footer_df,
    notes_tex,
    render_options,
    custom_index_names,
    custom_model_names,
    left_decimals,
    sig_digits,
    show_footer,
):
    """Return estimation table in LaTeX format as string.

    Args:
        body_df (pandas.DataFrame): the processed dataframe with parameter values and
            precision (if applied) as strings.
        footer_df (pandas.DataFrame): the processed dataframe with summary statistics as
            strings.
        notes_tex (str): a string with LaTex code for the notes section
        render_options(dict): the pd.to_latex() kwargs to apply if default options
            need to be updated.
        lef_decimals (int): see main docstring
        sig_digits (int): see main docstring
        show_footer (bool): see main docstring

    Returns:
        latex_str (str): the string for LaTex table script.

    """
    n_levels = body_df.index.nlevels
    n_columns = len(body_df.columns)
    # here you add all arguments of df.to_latex for which you want to change the default
    default_options = {
        "index_names": False,
        "escape": False,
        "na_rep": "",
        "column_format": "l" * n_levels
        + "S[table-format ={}.{}]".format(left_decimals, sig_digits) * n_columns,
        "multicolumn_format": "c",
    }
    if custom_index_names:
        default_options.update({"index_names": True})
    if render_options:
        default_options.update(render_options)
    if not default_options["index_names"]:
        body_df.index.names = [None] * body_df.index.nlevels
    latex_str = body_df.to_latex(**default_options)
    if custom_model_names:
        temp_str = "\n"
        for k in custom_model_names:
            max_col = max(custom_model_names[k]) + n_levels + 1
            min_col = min(custom_model_names[k]) + n_levels + 1
            temp_str += f"\\cmidrule(lr){{{min_col}-{max_col}}}"
            temp_str += "\n"
        latex_str = (
            latex_str.split("\\\\", 1)[0]
            + "\\\\"
            + temp_str
            + latex_str.split("\\\\", 1)[1]
        )
    latex_str = latex_str.split("\\bottomrule")[0]
    if show_footer:
        stats_str = footer_df.to_latex(**default_options)
        stats_str = (
            "\\midrule" + stats_str.split("\\midrule")[1].split("\\bottomrule")[0]
        )
        latex_str += stats_str
    latex_str += notes_tex
    latex_str += "\\bottomrule\n\\end{tabular}\n"
    if latex_str.startswith("\\begin{table}"):
        latex_str += "\n\\end{table}\n"
    return latex_str