示例#1
0
    def createLatex(self, parent, token, page):

        env = latex.Environment(parent, token['command'])
        style = latex.parse_style(token)

        width = style.get('width', None)
        if width and token(0).name == 'Image':
            token(0).set('style', 'width:{};'.format(width))

        if style.get('text-align', None) == 'center':
            latex.Command(env, 'centering')

        return env
示例#2
0
    def createLatex(self, parent, token, page):

        env = latex.Environment(parent, token['command'])
        style = latex.parse_style(token)

        width = style.get('width', None)
        if width and token(0).name == 'Image':
            token(0).set('style', 'width:{};'.format(width))

        if style.get('text-align', None) == 'center':
            latex.Command(env, 'centering')

        return env
示例#3
0
    def latexImage(self, parent, token, page, src):

        args = []
        style = latex.parse_style(token)
        width = style.get('width', None)
        if width:
            if width.endswith('%'):
                width = u'{}\\textwidth'.format(int(width[:-1])/100.)
            args.append(latex.Bracket(string=u'width={}'.format(width), escape=False))

        if style.get('text-align', None) == 'center':
            env = latex.Environment(parent, 'center')
        else:
            env = parent

        node = self.translator.findPage(src)
        fname = os.path.join(self.translator.destination, node.local)
        img = latex.Command(env, 'includegraphics', string=fname, args=args, escape=False)
        return img
示例#4
0
    def createLatex(self, parent, token, page):

        args = []
        style = latex.parse_style(token)
        width = style.get('width', None)
        if width:
            if width.endswith('%'):
                width = u'{}\\textwidth'.format(int(width[:-1])/100.)
            args.append(latex.Brace(string=width, escape=False))
            token.children[0]['width'] = width
        else:
            args.append(latex.Brace(string=u'\\textwidth', escape=False))

        if (len(token.children) > 1) and (token.children[1].name == 'CardTitle'):
            title = latex.Brace()
            self.translator.renderer.render(title, token.children[1], page)
            token.children[1].parent = None
            args.append(title)

        return latex.Environment(latex.Environment(parent, 'center'), 'card', args=args)