Skip to content

ENH: short caption for LaTeX tables #36267

Closed
@ivanovmg

Description

@ivanovmg

Is your feature request related to a problem?

DataFrame.to_latex() does not allow one to specify short caption.
Short caption is useful for the creation of neat-looking list of tables, where the caption is short, fitting into one line.

Describe the solution you'd like

Either add kwarg short_caption to to_latex method.
Alternatively expand the meaning of kwarg caption, so that it can optionally be unpacked into full_caption, short_caption.

API breaking implications

No.

Describe alternatives you've considered

No.

Additional context

Example of LaTeX table with short caption.

\begin{table}
  \centering
  \caption[Short caption]{Long-long full caption}
  \label{tab:label}
  \begin{tabular}{lr}
    \toprule
    Col1 & Col2 \\
    \midrule
    1 & 3 \\
    2 & 4 \\
    \bottomrule
  \end{tabular}
\end{table}

Possible code snippet:

df = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
df.to_latex(caption=('long caption', 'short caption'))

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions