Source code for mojo.latex.pyTitlePage
"""
pyTitlePage - create title page
===============================
"""
# create title page
[docs]class PyTitlePage:
"""create title page
:param titleType: type, options: 'user', 'auto'
:type titleType: str
:param content: content (used if titleType = 'user')
:type content: str
:param title: title of document (used if titleType = 'auto')
:type title: str
:param author: author of document (used if titleType = 'auto')
:type author: str
:param date: date of document (used if titleType = 'auto')
:type date: str
"""
def __init__(self, titleType="", content="", title="", author="", date="", verbose=0):
"""initialize class
**parameters**:
* **titleType** - type, options: 'user', 'auto'
* **content** - content (used if titleType = 'user')
* **title** - title of document (used if titleType = 'auto')
* **author** - author of document (used if titleType = 'auto')
* **date** - date of document (used if titleType = 'auto')
"""
self.verbose = verbose
self.titleType = titleType.lower()
if self.titleType == "user":
self.content = content
elif self.titleType == "auto":
self.title = title
self.author = author
self.date = date
else:
print(f"WARNING: titleType '{self.titleType}' not supported in class pyTitlePage.")
if self.verbose > 1:
print(f"set '{self.titleType}' title page")
# string instance of class
def __str__(self):
"""string instance of class
"""
if self.titleType == "user":
titleText = f"\\begin{{titlepage}}\n{self.content}\n\\end{{titlepage}}\n"
elif self.titleType == "auto":
titleList = []
if self.title:
titleList.append(f"\\title{{{self.title}}}")
if self.author:
titleList.append(f"\\author{{{self.author}}}")
if self.date:
titleList.append(f"\\date{{{self.date}}}")
if titleList:
titleList.append("\\maketitle\n")
titleText = "\n".join(titleList)
else:
titleText = ""
return titleText