diff --git a/pandas/core/config_init.py b/pandas/core/config_init.py index cf41bcff3d0c8..3f7363836acdb 100644 --- a/pandas/core/config_init.py +++ b/pandas/core/config_init.py @@ -816,9 +816,11 @@ def register_converter_cb(key): The specifier for vertical alignment of sparsified LaTeX multirows. """ -styler_multicol_align = """ -: {"r", "c", "l"} - The specifier for horizontal alignment of sparsified LaTeX multicolumns. +styler_multicol_align = r""" +: {"r", "c", "l", "naive-l", "naive-r"} + The specifier for horizontal alignment of sparsified LaTeX multicolumns. Pipe + decorators can also be added to non-naive values to draw vertical + rules, e.g. "\|r" will draw a rule on the left side of right aligned merged cells. """ styler_environment = """ @@ -918,11 +920,13 @@ def register_converter_cb(key): validator=is_one_of_factory(["c", "t", "b", "naive"]), ) + val_mca = ["r", "|r|", "|r", "r|", "c", "|c|", "|c", "c|", "l", "|l|", "|l", "l|"] + val_mca += ["naive-l", "naive-r"] cf.register_option( "latex.multicol_align", "r", styler_multicol_align, - validator=is_one_of_factory(["r", "c", "l", "naive-l", "naive-r"]), + validator=is_one_of_factory(val_mca), ) cf.register_option( diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 2fbd9506e391a..a454980138369 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -530,8 +530,11 @@ def to_latex( multicol_align : {"r", "c", "l", "naive-l", "naive-r"}, optional If sparsifying hierarchical MultiIndex columns whether to align text at the left, centrally, or at the right. If not given defaults to - ``pandas.options.styler.latex.multicol_align``. If a naive option is - given renders without multicol. + ``pandas.options.styler.latex.multicol_align``, which is "r". + If a naive option is given renders without multicol. + Pipe decorators can also be added to non-naive values to draw vertical + rules, e.g. "\|r" will draw a rule on the left side of right aligned merged + cells. .. versionchanged:: 1.4.0 siunitx : bool, default False