This commit is contained in:
2017-05-19 17:43:16 +02:00
parent c489ce7d1e
commit 6599ccb39f
23 changed files with 563 additions and 150 deletions

View File

@@ -1,18 +1,19 @@
# -*- encoding: utf-8 -*-
from .formatter import formatter
from .element import element
class resizebox:
class resizebox(element):
""" Class representing a latex resizebox. """
fmt = formatter({
templates = {
'content': """\\resizebox{{{width}}}{{{height}}}{{
{inner}
}}"""
})
}
def __init__(self, inner, width, height="!"):
def __init__(self, content=None, parent=None,
width="\\linewidth", height="!"):
""" Create a resizebox with given width and height.
Parameters:
@@ -24,15 +25,15 @@ class resizebox:
- str Use as it is (e.g. "0.5\\linewidth", "!").
- others Use as a percentage of linewidth (e.g. 0.5).
"""
self.inner = inner
super().__init__(parent, content)
self.width = width
if type(width) != 'str':
if type(width) is not str:
self.width = '{}\\linewidth'.format(width)
self.height = height
def __str__(self):
return self.fmt.format('content', {
def content(self):
return self.fmt().format('content', {
'width': self.width,
'height': self.height,
'inner': self.inner
'inner': super().content()
})