38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
# -*- encoding: utf-8 -*-
|
|
|
|
from .element import element
|
|
|
|
|
|
class resizebox(element):
|
|
""" Class representing a latex resizebox. """
|
|
|
|
templates = {
|
|
"content": """\\resizebox{{{width}}}{{{height}}}{{
|
|
{inner}
|
|
}}"""
|
|
}
|
|
|
|
def __init__(self, content=None, parent=None, width="\\linewidth", height="!"):
|
|
""" Create a resizebox with given width and height.
|
|
|
|
Parameters:
|
|
- width Width of the box.
|
|
- height Height of the box.
|
|
|
|
The width / height parameters work differently depending on their
|
|
types:
|
|
- str Use as it is (e.g. "0.5\\linewidth", "!").
|
|
- others Use as a percentage of linewidth (e.g. 0.5).
|
|
"""
|
|
super().__init__(parent, content)
|
|
self.width = width
|
|
if type(width) is not str:
|
|
self.width = "{}\\linewidth".format(width)
|
|
self.height = height
|
|
|
|
def content(self):
|
|
return self.fmt().format(
|
|
"content",
|
|
{"width": self.width, "height": self.height, "inner": super().content()},
|
|
)
|