From dfb282cd7e35a967f10ac73ded6e3d0d7fadab3e Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (MBP)" Date: Sun, 19 Sep 2021 09:17:44 +0200 Subject: [PATCH 1/4] update docs for multicol_align --- pandas/core/config_init.py | 4 +++- pandas/io/formats/style.py | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pandas/core/config_init.py b/pandas/core/config_init.py index cf41bcff3d0c8..442785b8db83d 100644 --- a/pandas/core/config_init.py +++ b/pandas/core/config_init.py @@ -918,11 +918,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..b7339fc91c5a7 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -530,8 +530,10 @@ 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 right side of merged cells. .. versionchanged:: 1.4.0 siunitx : bool, default False From 7a98f52be123467898de65f7782c23ea34b7ed26 Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (MBP)" Date: Sun, 19 Sep 2021 09:21:53 +0200 Subject: [PATCH 2/4] update docs for multicol_align --- pandas/core/config_init.py | 6 ++++-- pandas/io/formats/style.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pandas/core/config_init.py b/pandas/core/config_init.py index 442785b8db83d..1165ff3512876 100644 --- a/pandas/core/config_init.py +++ b/pandas/core/config_init.py @@ -817,8 +817,10 @@ def register_converter_cb(key): """ styler_multicol_align = """ -: {"r", "c", "l"} - The specifier for horizontal alignment of sparsified LaTeX multicolumns. +: {"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 = """ diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index b7339fc91c5a7..3158daaac5471 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -533,7 +533,8 @@ def to_latex( ``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 right side of merged cells. + 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 From afb6c001b944f254cd115d334acad36a53dacf21 Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Mon, 20 Sep 2021 17:17:35 +0200 Subject: [PATCH 3/4] special char fix --- pandas/io/formats/style.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 3158daaac5471..a454980138369 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -533,7 +533,7 @@ def to_latex( ``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 + rules, e.g. "\|r" will draw a rule on the left side of right aligned merged cells. .. versionchanged:: 1.4.0 From aab18a922034434c7f231c57594787f2e28520fe Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Mon, 20 Sep 2021 17:21:05 +0200 Subject: [PATCH 4/4] special char fix --- pandas/core/config_init.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/config_init.py b/pandas/core/config_init.py index 1165ff3512876..3f7363836acdb 100644 --- a/pandas/core/config_init.py +++ b/pandas/core/config_init.py @@ -816,11 +816,11 @@ def register_converter_cb(key): The specifier for vertical alignment of sparsified LaTeX multirows. """ -styler_multicol_align = """ +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. + rules, e.g. "\|r" will draw a rule on the left side of right aligned merged cells. """ styler_environment = """