Skip to content
Open
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
34 changes: 34 additions & 0 deletions pylatex/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ class LongTable(Tabular):
header = False
foot = False
lastFoot = False # noqa, casing is needed for backwards compatibility
caption = None

def end_table_header(self):
r"""End the table header which will appear on every page."""
Expand Down Expand Up @@ -530,6 +531,39 @@ def end_table_last_footer(self):

self.append(Command("endlastfoot"))

def add_caption(self, caption):
"""Add a caption to the float.

Args
----
caption: str
The text of the caption.
"""

self.caption = Command("caption", caption)

def dumps_content(self, **kwargs):
r"""Represent the content of the tabular in LaTeX syntax.

This adds the top and bottomrule when using a booktabs style tabular.

Args
----
\*\*kwargs:
Arguments that can be passed to `~.dumps_list`

Returns
-------
string:
A LaTeX string representing the
"""

content = ""
if self.caption is not None:
content += self.caption.dumps() + "\\\\%\n"
content += super().dumps_content(**kwargs)
return NoEscape(content)


class LongTabu(LongTable, Tabu):
"""A class that represents a longtabu (more flexible multipage table)."""
Expand Down