From 3743212f1de4731349a6330e061772b5473663ec Mon Sep 17 00:00:00 2001 From: skimprem Date: Wed, 3 Jan 2024 10:15:09 +0600 Subject: [PATCH 1/4] Add "short title" option to Section class --- pylatex/section.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pylatex/section.py b/pylatex/section.py index 493887a5..a58451cc 100644 --- a/pylatex/section.py +++ b/pylatex/section.py @@ -25,7 +25,7 @@ class Section(Container): #: subclasses will also have the new default. numbering = True - def __init__(self, title, numbering=None, *, label=True, **kwargs): + def __init__(self, title, short=None, numbering=None, *, label=True, **kwargs): """ Args ---- @@ -39,6 +39,8 @@ def __init__(self, title, numbering=None, *, label=True, **kwargs): """ self.title = title + if short is not None: + self.short = short if numbering is not None: self.numbering = numbering @@ -71,7 +73,7 @@ def dumps(self): else: num = "" - string = Command(self.latex_name + num, self.title).dumps() + string = Command(self.latex_name + num, self.title, self.short).dumps() if self.label is not None: string += "%\n" + self.label.dumps() string += "%\n" + self.dumps_content() From 3384a978edc426b4b580cf4dc937fea39a418c96 Mon Sep 17 00:00:00 2001 From: Roman Sermyagin Date: Wed, 3 Jan 2024 10:22:47 +0600 Subject: [PATCH 2/4] Fix short in section --- pylatex/section.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pylatex/section.py b/pylatex/section.py index a58451cc..be68a4e7 100644 --- a/pylatex/section.py +++ b/pylatex/section.py @@ -39,8 +39,7 @@ def __init__(self, title, short=None, numbering=None, *, label=True, **kwargs): """ self.title = title - if short is not None: - self.short = short + self.short = short if numbering is not None: self.numbering = numbering From 584d6dee67cb8574c7c749c8625a48efdb5fba9b Mon Sep 17 00:00:00 2001 From: skimprem Date: Fri, 26 Jul 2024 01:17:04 +0500 Subject: [PATCH 3/4] Update section.py put the argument after the *, so that it's not a breaking change in the API --- pylatex/section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylatex/section.py b/pylatex/section.py index be68a4e7..03a80071 100644 --- a/pylatex/section.py +++ b/pylatex/section.py @@ -25,7 +25,7 @@ class Section(Container): #: subclasses will also have the new default. numbering = True - def __init__(self, title, short=None, numbering=None, *, label=True, **kwargs): + def __init__(self, title, numbering=None, *, short=None, label=True, **kwargs): """ Args ---- From f64a7dea53dd0fb4240cd1590f29f2eb807c1850 Mon Sep 17 00:00:00 2001 From: skimprem Date: Fri, 26 Jul 2024 01:19:03 +0500 Subject: [PATCH 4/4] Update section.py update the docstring --- pylatex/section.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pylatex/section.py b/pylatex/section.py index 03a80071..6b2bd855 100644 --- a/pylatex/section.py +++ b/pylatex/section.py @@ -33,6 +33,8 @@ def __init__(self, title, numbering=None, *, short=None, label=True, **kwargs): The section title. numbering: bool Add a number before the section title. + short: str + The short section title. label: Label or bool or str Can set a label manually or use a boolean to set preference between automatic or no label