Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Short title" option for the Section class #380

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
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
7 changes: 5 additions & 2 deletions pylatex/section.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,23 @@ 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, numbering=None, *, short=None, label=True, **kwargs):
"""
Args
----
title: str
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
"""

self.title = title
self.short = short

if numbering is not None:
self.numbering = numbering
Expand Down Expand Up @@ -71,7 +74,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()
Expand Down