首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PyLatex如何添加自定义使用包

PyLatex如何添加自定义使用包
EN

Stack Overflow用户
提问于 2017-01-29 22:09:14
回答 1查看 4K关注 0票数 8

我想知道是哪个命令将定制的use添加到pylatex。我已经尝试过使用document.append函数和document.preamble.append函数,但是仍然会出现错误。

代码语言:javascript
复制
# encoding=utf-8

from pylatex import Document, Section, Subsection, Command
from pylatex.utils import italic, NoEscape
from pylatex.package import Package
from pylatex import Document, Section, UnsafeCommand
from pylatex.base_classes import Environment, CommandBase, Arguments





def fill_document(doc):
"""Add a section, a subsection and some text to the document.

:param doc: the document
:type doc: :class:`pylatex.document.Document` instance
"""
with doc.create(Section('A section')):
    doc.append('Some regular text and some ')
    doc.append(italic('italic text. '))

    with doc.create(Subsection('A subsection')):
        doc.append('Also some crazy characters: $&#{}')


if __name__ == '__main__':
# Basic document
doc = Document('basic')
fill_document(doc)

doc.generate_pdf(clean_tex=False)
doc.generate_tex()

# Document with `\maketitle` command activated
doc = Document()

#packages = [Package('caratula',"showRevisiones")]


#doc.append(Package("caratula"))

doc.data.append(Package("caratula"))

doc.preamble.append(Command('begin', 'document'))
doc.preamble.append(Command('materia', 'Materia del Apunte'))
doc.preamble.append(Command('tipoapunte', str('Tipo de Apunte (Teorico o       Practico)')))
doc.preamble.append(Command('fecha', NoEscape(r'\today')))
doc.preamble.append(Command('tema', NoEscape(r'Tema')))
doc.preamble.append(Command('subtema', NoEscape(r'Subtema')))
doc.preamble.append(Command('autor',["Apellido", "Nombre2", "002/01","email2@dominio.com"]))
doc.preamble.append(Command('revision',["05/01/2015", "Apellido, Nombre2", "em"]))
doc.append(NoEscape(r'\maketitle'))

fill_document(doc)

doc.generate_pdf('basic_maketitle', clean_tex=False)

# Add stuff to the document
with doc.create(Section('A second section')):
    doc.append('Some text.')

doc.generate_pdf('basic_maketitle2', clean_tex=False)
tex = doc.dumps()  # The document as string in LaTeX syntax


import subprocess
subprocess.Popen("basic_maketitle2.tex",shell=True)
EN

回答 1

Stack Overflow用户

发布于 2017-02-19 14:21:39

你所说的定制包裹是什么意思?如果您指的是您创建的.sty文件,那么我不知道(可能是相同的),但是如果您只想添加一个标准包,那么。

代码语言:javascript
复制
doc.packages.append(Package('tikz'))

为我工作(从幽门进口包装后)。

干杯。

票数 11
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41926515

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档