diff --git a/pandas/io/formats/style_render.py b/pandas/io/formats/style_render.py index 2c862f2f4ed96..27a5170e48949 100644 --- a/pandas/io/formats/style_render.py +++ b/pandas/io/formats/style_render.py @@ -740,7 +740,7 @@ def _translate_latex(self, d: dict) -> None: "display_value": col["display_value"] if col["is_visible"] else "", - "cellstyle": self.ctx_index[r, c] if col["is_visible"] else [], + "cellstyle": self.ctx_index[r, c], } for c, col in enumerate(row[:index_levels]) if (col["type"] == "th" and not self.hide_index_[c]) diff --git a/pandas/tests/io/formats/style/test_to_latex.py b/pandas/tests/io/formats/style/test_to_latex.py index cb9894a661d6e..f513b0d8a197e 100644 --- a/pandas/tests/io/formats/style/test_to_latex.py +++ b/pandas/tests/io/formats/style/test_to_latex.py @@ -753,7 +753,7 @@ def test_apply_map_header_render_mi(df_ext, index, columns, siunitx): expected_index = dedent( """\ \\multirow[c]{2}{*}{\\bfseries{A}} & a & 0 & -0.610000 & ab \\\\ - & b & 1 & -1.220000 & cd \\\\ + \\bfseries{} & b & 1 & -1.220000 & cd \\\\ B & \\bfseries{c} & 2 & -2.220000 & de \\\\ """ ) @@ -840,7 +840,7 @@ def test_latex_hiding_index_columns_multiindex_alignment(): i-0 & i-2 & & & \\\\ i0 & \\color{blue} j2 & \\color{red} 5 & 6 & 7 \\\\ \\multirow[c]{2}{*}{\\color{blue} j0} & i2 & 9 & 10 & 11 \\\\ - & \\color{blue} j2 & 13 & 14 & 15 \\\\ + \\color{blue} & \\color{blue} j2 & 13 & 14 & 15 \\\\ \\end{tabular} """ )