45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
# -*- encoding: utf-8 -*-
|
|
|
|
from .element import element
|
|
|
|
|
|
class makebox(element):
|
|
""" Class representing an unindented makebox. """
|
|
|
|
templates = {
|
|
"content": """{noindent}\\makebox[{width}]{{
|
|
{inner}
|
|
}}"""
|
|
}
|
|
|
|
def __init__(self, content=None, parent=None, width=None, noindent=True):
|
|
""" Create a new makebox with given width.
|
|
|
|
Parameters:
|
|
- width Width of the box (string, float, or None). If float,
|
|
represent a percentage of \\textwidth. None is used to have
|
|
\\textwidth.
|
|
- noindent Add a \\noindent command before the box.
|
|
"""
|
|
super().__init__(parent, content)
|
|
|
|
self.width = width
|
|
if self.width is None:
|
|
self.width = "\\textwidth"
|
|
elif type(self.width) != "str":
|
|
self.width = "{}\\textwidth".format(self.width)
|
|
|
|
self.noindent = ""
|
|
if self.noindent:
|
|
self.noindent = "\\noindent"
|
|
|
|
def content(self):
|
|
return self.fmt().format(
|
|
"content",
|
|
{
|
|
"inner": super().content(),
|
|
"width": self.width,
|
|
"noindent": self.noindent,
|
|
},
|
|
)
|