Initial commit.
This commit is contained in:
38
pyltk/resizebox.py
Normal file
38
pyltk/resizebox.py
Normal 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
|
||||
})
|
||||
Reference in New Issue
Block a user