Initial commit.

This commit is contained in:
2017-05-16 11:00:50 +02:00
commit c489ce7d1e
16 changed files with 425 additions and 0 deletions

38
pyltk/resizebox.py Normal file
View File

@@ -0,0 +1,38 @@
# -*- encoding: utf-8 -*-
from .formatter import formatter
class resizebox:
""" Class representing a latex resizebox. """
fmt = formatter({
'content': """\\resizebox{{{width}}}{{{height}}}{{
{inner}
}}"""
})
def __init__(self, inner, width, 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).
"""
self.inner = inner
self.width = width
if type(width) != 'str':
self.width = '{}\\linewidth'.format(width)
self.height = height
def __str__(self):
return self.fmt.format('content', {
'width': self.width,
'height': self.height,
'inner': self.inner
})