Skip to content

DOC: expand allowed vals for multicol_align #43656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pandas/core/config_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand Down Expand Up @@ -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(
Expand Down
7 changes: 5 additions & 2 deletions pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down