@@ -3227,6 +3227,7 @@ def to_latex(
3227
3227
def to_latex (
3228
3228
self ,
3229
3229
buf : FilePath | WriteBuffer [str ] | None = None ,
3230
+ * ,
3230
3231
columns : Sequence [Hashable ] | None = None ,
3231
3232
col_space : ColspaceArgType | None = None ,
3232
3233
header : bool_t | Sequence [str ] = True ,
@@ -3270,6 +3271,9 @@ def to_latex(
3270
3271
The subset of columns to write. Writes all columns by default.
3271
3272
col_space : int, optional
3272
3273
The minimum width of each column.
3274
+
3275
+ .. deprecated:: 1.5.0
3276
+ Whitespace does not affect a rendered LaTeX file and is ignored.
3273
3277
header : bool or list of str, default True
3274
3278
Write out the column names. If a list of strings is given,
3275
3279
it is assumed to be aliases for the column names.
@@ -3366,6 +3370,13 @@ def to_latex(
3366
3370
\bottomrule
3367
3371
\end{{tabular}}
3368
3372
"""
3373
+ msg = (
3374
+ "`col_space` is deprecated. Whitespace in LaTeX does not impact "
3375
+ "the rendered version, and this argument is ignored."
3376
+ )
3377
+ if col_space is not None :
3378
+ warnings .warn (msg , DeprecationWarning , stacklevel = find_stack_level ())
3379
+
3369
3380
# Get defaults from the pandas config
3370
3381
if self .ndim == 1 :
3371
3382
self = self .to_frame ()
@@ -3382,6 +3393,9 @@ def to_latex(
3382
3393
3383
3394
if column_format is not None and not isinstance (column_format , str ):
3384
3395
raise ValueError ("`column_format` must be str or unicode" )
3396
+ length = len (self .columns ) if columns is None else len (columns )
3397
+ if isinstance (header , (list , tuple )) and len (header ) != length :
3398
+ raise ValueError (f"Writing { length } cols but got { len (header )} aliases" )
3385
3399
3386
3400
# Refactor formatters/float_format/decimal/na_rep/escape to Styler structure
3387
3401
base_format_ = {
0 commit comments