Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
It would be nice to be able to use the =
option with multirow. Maybe this is something that can be decided automatically according to the column type.
Feature Description
Add logic to _parse_latex_header_span()
to check for cloumn types.
IF columntype NOT ONE OF l, c, r
RETURN f"\\multirow[{multirow_align}]{{{rowspan}}}{{*}}{{{display_val}}}"
ELSE
RETURN f"\\multirow[{multirow_align}]{{{rowspan}}}{{=}}{{{display_val}}}"
Alternative Solutions
One could also find/replace the return value of pandas.DataFrame.to_latex
manually:
df = pd.read_excel("input.xlsx")
df = df.set_index(df.columns[:3].tolist())
df = df.sort_index(multirow=True)
latex = df.to_latex()
latex = latex.replace("{*}", "{=}")
with open("output.tex", "w") as f:
f.write(latex)
Additional Context
pandas/pandas/io/formats/style_render.py
Line 2451 in 156e67e
See this snippet from the multirow documentation:
The width can also be given as = when the \multirow entry is given in a column that has a defined width, for example in a p{} column, an X column in tabularx or a L, C, R or J column in a tabulary environment. The text will be set in a \parbox of that width. If you give “=” in other situations, you will get strange results (usually a too wide column).