当前位置: 首页>>代码示例>>Python>>正文


Python Document.append方法代码示例

本文整理汇总了Python中pylatex.Document.append方法的典型用法代码示例。如果您正苦于以下问题:Python Document.append方法的具体用法?Python Document.append怎么用?Python Document.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylatex.Document的用法示例。


在下文中一共展示了Document.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_document

# 需要导入模块: from pylatex import Document [as 别名]
# 或者: from pylatex.Document import append [as 别名]
def test_document():
    geometry_options = {
        "includeheadfoot": True,
        "headheight": "12pt",
        "headsep": "10pt",
        "landscape": True
    }

    doc = Document(
        default_filepath='default_filepath',
        documentclass='article',
        fontenc='T1',
        inputenc='utf8',
        lmodern=True,
        data=None,
        page_numbers=True,
        indent=False,
        document_options=["a4paper", "12pt"],
        geometry_options=geometry_options
    )

    repr(doc)

    doc.append('Some text.')
    doc.change_page_style(style="empty")
    doc.change_document_style(style="plain")
    doc.add_color(name="lightgray", model="gray", description="0.6")
    doc.add_color(name="abitless", model="gray", description="0.8")
    doc.set_variable(name="myVar", value="1234")
    doc.set_variable(name="myVar", value="1234")
    doc.change_length(parameter=r"\headheight", value="0.5in")

    doc.generate_tex(filepath='')
    doc.generate_pdf(filepath='', clean=True)
开发者ID:vovchikthebest,项目名称:PyLaTeX,代码行数:36,代码来源:args.py

示例2: arxiv_search

# 需要导入模块: from pylatex import Document [as 别名]
# 或者: from pylatex.Document import append [as 别名]
def arxiv_search(search_query):

    url = 'http://export.arxiv.org/api/query?search_query=all:' + \
        search_query + '&start=0&max_results=5'
    data = urllib.request.urlopen(url).read()

    soup = bs(data, features='xml')
    title_array = []
    summary_array = []

    for i in soup.findAll('title'):
        title_array.append(i)

    for i in soup.findAll('summary'):
        summary_array.append(i)

    doc = Document()
    doc.packages.append(
        Package(
            'geometry',
            options=[
                'tmargin=1cm',
                'lmargin=1cm',
                'rmargin=1cm']))

    with doc.create(Section('Search results for \"' + search_query + '\"')):

        for i in range(1, 5):
            doc.append(Subsection(italic(title_array[i].string)))
            doc.append(summary_array[i].string)

    doc.generate_pdf()
开发者ID:arecibokck,项目名称:Moonlight,代码行数:34,代码来源:arxiv.py

示例3: circuit_to_pdf_using_qcircuit_via_tex

# 需要导入模块: from pylatex import Document [as 别名]
# 或者: from pylatex.Document import append [as 别名]
def circuit_to_pdf_using_qcircuit_via_tex(circuit: circuits.Circuit,
                                          filepath: str,
                                          pdf_kwargs=None,
                                          qcircuit_kwargs=None,
                                          clean_ext=('dvi', 'ps'),
                                          documentclass='article'):
    """Compiles the QCircuit-based latex diagram of the given circuit.

    Args:
        circuit: The circuit to produce a pdf of.
        filepath: Where to output the pdf.
        pdf_kwargs: The arguments to pass to generate_pdf.
        qcircuit_kwargs: The arguments to pass to
            circuit_to_latex_using_qcircuit.
        clean_ext: The file extensions to clean up after compilation. By
            default, latexmk is used with the '-pdfps' flag, which produces
            intermediary dvi and ps files.
        documentclass: The documentclass of the latex file.
    """
    pdf_kwargs = {'compiler': 'latexmk', 'compiler_args': ['-pdfps'],
                  **({} if pdf_kwargs is None else pdf_kwargs)}
    qcircuit_kwargs = {} if qcircuit_kwargs is None else qcircuit_kwargs
    tex = circuit_to_latex_using_qcircuit(circuit, **qcircuit_kwargs)
    doc = Document(documentclass=documentclass, document_options='dvips')
    doc.packages.append(Package('amsmath'))
    doc.packages.append(Package('qcircuit'))
    doc.append(NoEscape(tex))
    doc.generate_pdf(filepath, **pdf_kwargs)
    for ext in clean_ext:
        try:
            os.remove(filepath + '.' + ext)
        except (OSError, IOError) as e:
            if e.errno != errno.ENOENT:
                raise
开发者ID:google2013,项目名称:Cirq,代码行数:36,代码来源:qcircuit_pdf.py

示例4: generate_info_report

# 需要导入模块: from pylatex import Document [as 别名]
# 或者: from pylatex.Document import append [as 别名]
def generate_info_report():
			"""
			Generate a report with cover, status und last 2 lines in log for every test
			"""

			## Define the geometry for LaTeX files
			geometry_options = {
					"head": "40pt",
					"margin": "0.5in",
					"bottom": "0.6in",
					"includeheadfoot": True
				}


			## Create the LaTeX object, a instance of Document Class
			doc = Document(documentclass='article', geometry_options=geometry_options)

			## Add cover
			generate_cover2(doc)
			doc.append(NewPage())

			## Add status table
			generate_status_tabel(doc)
			doc.append(NewPage())

			## Add last 2 lines in log.txt
			for i in range(1, 4):
					generate_info_list(doc, i)


			doc.generate_pdf("RiMEA-Projekt Analyse", clean_tex=False)
开发者ID:JuPedSim,项目名称:jpscore,代码行数:33,代码来源:reportscript.py

示例5: test

# 需要导入模块: from pylatex import Document [as 别名]
# 或者: from pylatex.Document import append [as 别名]
def test():
    doc = Document("utils_escape_latex")
    section = Section('Escape LaTeX characters test')

    text = escape_latex('''\
    & (ampersand)
    % (percent)
    $ (dollar)
    # (number)
    _ (underscore)
    { (left curly brace)
    } (right curly brace)
    ~ (tilde)
    ^ (caret)
    \\ (backslash)
    --- (three minuses)
    a\xA0a (non breaking space)
    [ (left bracket)
    ] (right bracket)
    ''')

    section.append(text)
    doc.append(section)

    doc.generate_pdf()
开发者ID:JelteF,项目名称:PyLaTeX,代码行数:27,代码来源:test_utils_escape_latex.py

示例6: build_document

# 需要导入模块: from pylatex import Document [as 别名]
# 或者: from pylatex.Document import append [as 别名]
def build_document(transcript):
    """
    Processes a Transcript object to build a LaTeX document.
    """
    # Open temporary file
    doc = Document(documentclass='scrartcl', title=transcript.title,
                   subtitle=transcript.school,
                   author=transcript.student,
                   date=transcript.date.strftime('%d %B %Y'), temporary=True)

    doc.packages.append(Package('geometry', option='margin=1.0in'))
    doc.preamble.append(Command('renewcommand', argument=['\\familydefault', '\\sfdefault']))

    doc.append(Command('maketitle'))

    # Iterate through each transcript section
    for t_section in transcript.sections:
        # Create new section
        s = Section(escape_latex(t_section.title))
        # Add content to section
        for s_line in t_section.content:
            s_line = '\t'.join(s_line)
            s.append(escape_latex(s_line) + ' \\\n')

        # Add subsections to section
        for t_subsection in t_section.subsections:
            ss = Subsection(escape_latex(t_subsection.title))
            num_cols = max(len(l) for l in t_subsection.content)
            ss_table = Table(' l ' * num_cols)
            # Add content to subsection
            for ss_line in t_subsection.content:

                ss_line = '\t'.join(ss_line)
                if ss_line.startswith('Course Topic'):
                    ss_table.append('&')
                    ss_table.add_multicolumn(num_cols-1, 'l',
                                             escape_latex(ss_line))
                    ss_table.append(r'\\')
                elif not ss_line[:3].isupper() and not ss_line.startswith('Test'):
                    ss_table.add_multicolumn(num_cols, 'l', escape_latex(ss_line))
                    ss_table.append(r'\\')
                else:
                    if ss_line.startswith('TERM'):
                        ss_table.add_hline()
                    filled = escape_latex(ss_line).split('\t')
                    filled += (num_cols - len(filled)) * ['']
                    ss_table.add_row(filled)

            ss.append(ss_table)
            s.append(ss)

        doc.append(s)
    doc.generate_pdf(clean=True)

    return doc
开发者ID:Rsullivan00,项目名称:transcript-to-latex,代码行数:57,代码来源:buildDocument.py

示例7: get_cv_doc

# 需要导入模块: from pylatex import Document [as 别名]
# 或者: from pylatex.Document import append [as 别名]
def get_cv_doc(filename):
    """Returns a pylatex.Document instance pre-loaded with everything needed for my cv style."""
    doc = Document(filename,
                   documentclass='article')

    # Set Packages
    doc.packages.append(Package('marginnote'))
    doc.packages.append(UnsafeCommand('reversemarginpar'))
    doc.packages.append(Package('graphicx'))
    doc.packages.append(Package('classicthesis', options='nochapters'))
    doc.packages.append(Package('currvita', options='LabelsAligned'))
    doc.packages.append(Package('hyperref'))
    doc.packages.append(UnsafeCommand('hypersetup', extra_arguments=r'colorlinks, breaklinks, urlcolor=Maroon, linkcolor=Maroon'))

    doc.packages.append(UnsafeCommand('newlength', r'\datebox', ))
    doc.packages.append(UnsafeCommand('settowidth', r'\datebox', extra_arguments='Tuebingen, Germany'))

    doc.packages.append(UnsafeCommand('renewcommand', r'\cvheadingfont', extra_arguments=r'\LARGE\color{Maroon}'))

    # Unchanged-ish (Extra line break at the end)
    doc.packages.append(UnsafeCommand('newcommand', r'\SubHeading', options=1,
                             extra_arguments=r'\vspace{1em}\noindent\spacedlowsmallcaps{#1}\vspace{0.7em}\\'))

    doc.packages.append(UnsafeCommand('newcommand', r'\Email', options=1,
                             extra_arguments=r'\href{mailto:#1}{#1}'))

    # Unchanged
    doc.packages.append(UnsafeCommand('newcommand', r'\MarginText', options=1, extra_arguments=r'\marginpar{\raggedleft\small#1}'))

    # Unchanged
    doc.packages.append(UnsafeCommand('newcommand', r'\Description', options=1,
                             extra_arguments=r'\hangindent=2em\hangafter=0\footnotesize{#1}\par\normalsize\vspace{1em}'))

    doc.packages.append(UnsafeCommand('newcommand', r'\DescMarg', options=2,
                             extra_arguments=r'\noindent\hangindent=2em\hangafter=0 \parbox{\datebox}{\small} \MarginText{#1} #2 \vspace{0.3em}\\'))

    ##################
    doc.packages.append(UnsafeCommand('newcommand', r'\HeaderOnly', options=2,
                                      extra_arguments= r'\noindent\hangindent=2em\hangafter=0 \parbox{\datebox}{\small \textit{#1}}\hspace{1.5em} #2 \vspace{0.5em}\\'))

    doc.packages.append(UnsafeCommand('newcommand', r'\EntryHeader', options=3,
                             extra_arguments=r'\noindent\hangindent=2em\hangafter=0 \parbox{\datebox}{\small \textit{#2}}\hspace{1.5em} \MarginText{#1} #3 \vspace{0.5em}'))

    doc.packages.append(UnsafeCommand('newcommand', r'\NewEntry', options=4,
            extra_arguments=r'\EntryHeader{#1}{#2}{#3}\\\Description{#4}'))




    # Fill Document
    doc.append(UnsafeCommand('thispagestyle', 'empty'))
    doc.append(NoEscape(r'\raggedright'))

    return doc
开发者ID:neuroneuro15,项目名称:my_cv,代码行数:56,代码来源:cv_preamble.py

示例8: test

# 需要导入模块: from pylatex import Document [as 别名]
# 或者: from pylatex.Document import append [as 别名]
def test():
    doc = Document()
    section = Section('Multirow Test')
    figure = Figure()
    image_filename = os.path.join(os.path.dirname(__file__),
                                  '../examples/kitten.jpg')
    figure.add_image(image_filename)
    figure.add_caption('Whoooo an imagage of a pdf')
    section.append(figure)
    doc.append(section)

    doc.generate_pdf()
开发者ID:votti,项目名称:PyLaTeX,代码行数:14,代码来源:pictures.py

示例9: _upload_problem

# 需要导入模块: from pylatex import Document [as 别名]
# 或者: from pylatex.Document import append [as 别名]
    def _upload_problem(self, problem):
        """Uploads a specified problem to imgur.

        Returns:
            A tuple (str, (int, int)), where str is the url, on imgur and
            the tuples are the dimensions of the image (width, height).
        Raises:
           LatexParsingException : there was an issue parsing the document
        """
        default_doc = []
        # populate doc with the appropriate problem
        for line in problem[0]:
            # these first two statements are for wrapping the title around in a minipage which allows
            # the problem to be generated on one page and doesn't invoke \newpage
            if line == '\\begin{document}':
                default_doc.append(NoEscape(line))
                default_doc.append(NoEscape('\\begin{minipage}{\\textwidth}'))
            elif line == '\\maketitle':
                default_doc.append(NoEscape(line))
                default_doc.append(NoEscape('\\end{minipage}'))
            elif line == '\\end{itemize}':
                for line2 in problem[1]:
                    default_doc.append(NoEscape(line2))
                default_doc.append(NoEscape(line))
            else:
                default_doc.append(NoEscape(line))

        doc_class_line = NoEscape(default_doc[0])
        use_pkg_line = NoEscape(default_doc[1])
        # skip twocolumn since it makes the problem look spread awfully
        opts = filter(lambda pkg: pkg != 'twocolumn', doc_class_line[doc_class_line.find('[') + 1: doc_class_line.find(']')].split(','))
        args = NoEscape(doc_class_line[doc_class_line.find('{') + 1: doc_class_line.find('}')])
        doc = Document(documentclass=Command('documentclass', options=opts, arguments=args))
        # load packages
        doc.packages = [Package(i) for i in use_pkg_line[use_pkg_line.find('{') + 1: use_pkg_line.find('}')].split(',')]
        # position right after \begin{document}
        it = 4
        while default_doc[it].strip() != '\end{document}':
            doc.append(NoEscape(default_doc[it]))
            it += 1
        # fail safe for future problems which may not parse correctly
        try:
            doc.generate_pdf('default', compiler="pdflatex")
        except:
            raise LatexParsingException

        # These are normal Linux commands that are used to convert the pdf
        # file created by pylatex into a snippet
        os.system("pdfcrop default.pdf")
        os.system("pdftoppm default-crop.pdf|pnmtopng > default.png")
        path = os.path.abspath('default.png')
        uploaded_image = self._client.upload_image(path, title="LaTeX")
        return uploaded_image.link, OnlineImage.get_local_image_info(path)
开发者ID:wgma00,项目名称:PokemonShowdownBot,代码行数:55,代码来源:Putnam.py

示例10: test

# 需要导入模块: from pylatex import Document [as 别名]
# 或者: from pylatex.Document import append [as 别名]
def test():
    doc = Document()
    Subsection('Only a single string', data='Some words')

    sec1 = Section('Only contains one subsection', data='Subsection')

    sec2 = Section('Only a single italic command', data=Command('textit',
                                                                'Hey'))
    sec2.append('something else that is not italic')
    doc.append(sec1)
    doc.append(sec2)

    doc.generate_pdf()
开发者ID:AnkurAgarwal1989,项目名称:PyLaTeX,代码行数:15,代码来源:test_no_list_as_data.py

示例11: test_document

# 需要导入模块: from pylatex import Document [as 别名]
# 或者: from pylatex.Document import append [as 别名]
def test_document():
    doc = Document(
        default_filepath="default_filepath",
        documentclass="article",
        fontenc="T1",
        inputenc="utf8",
        lmodern=True,
        data=None,
    )

    doc.append("Some text.")

    doc.generate_tex(filepath="")
    doc.generate_pdf(filepath="", clean=True)
开发者ID:markdoerr,项目名称:PyLaTeX,代码行数:16,代码来源:args.py

示例12: test_document

# 需要导入模块: from pylatex import Document [as 别名]
# 或者: from pylatex.Document import append [as 别名]
def test_document():
    doc = Document(
        default_filepath='default_filepath',
        documentclass='article',
        fontenc='T1',
        inputenc='utf8',
        lmodern=True,
        data=None,
    )

    repr(doc)

    doc.append('Some text.')

    doc.generate_tex(filepath='')
    doc.generate_pdf(filepath='', clean=True)
开发者ID:AnkurAgarwal1989,项目名称:PyLaTeX,代码行数:18,代码来源:args.py

示例13: test_document

# 需要导入模块: from pylatex import Document [as 别名]
# 或者: from pylatex.Document import append [as 别名]
def test_document():
    doc = Document(
        default_filepath='default_filepath',
        documentclass='article',
        fontenc='T1',
        inputenc='utf8',
        author='',
        title='',
        date='',
        data=None,
        maketitle=False
    )

    doc.append('Some text.')

    doc.generate_tex(filepath='')
    doc.generate_pdf(filepath='', clean=True)
开发者ID:rfilmyer,项目名称:PyLaTeX,代码行数:19,代码来源:args.py

示例14: __init__

# 需要导入模块: from pylatex import Document [as 别名]
# 或者: from pylatex.Document import append [as 别名]
class TrainingDocumentWriter:

    def __init__(self, title):
        self.title = title
        self.doc = Document(title)
        self.doc.packages.append(Package('geometry', options=['a4paper', 'top=2cm', 'bottom=2.5cm', 'left=2cm', 'right=2cm']))
        self.doc.packages.append(Package('titlesec', options=['sf']))
        self.doc.packages.append(Package('lmodern'))
        self.doc.append(Command('sffamily'))

        return


    def append_plot(self, pyplot, caption=''):
        with self.doc.create(Plt(position='htbp')) as plot:
            plot.add_plot(pyplot, width=ur'\textwidth')
            if caption!='':
                plot.add_caption(caption)

        return

    def append_section(self, section_title='', content=''):
        with self.doc.create(Section(section_title)):
            if content!='':
                self.doc.append(content)
        return

    def generate_pdf(self,filename=u'', clean=True, compiler='pdflatex'):

        #This is a workaround to save the generated pdf in a different directory (not in working dir)
        cur_path = os.getcwd()
        dirlist = filename.split('/')
        os.chdir(os.path.dirname(filename)) #cd to specified directory

        #Remove possible existing file extension (.pdf)
        if '.' in filename:
            self.doc.generate_pdf(dirlist[len(dirlist)-1].split('.')[0])
        else:
            self.doc.generate_pdf(dirlist[len(dirlist)-1])

        os.chdir(cur_path) #cd to original working directory

        return
开发者ID:mn033,项目名称:training_monitoring,代码行数:45,代码来源:docwriter.py

示例15: generate_eva_report

# 需要导入模块: from pylatex import Document [as 别名]
# 或者: from pylatex.Document import append [as 别名]
def generate_eva_report():
		"""
    Generate a report which contains the evacution time for every test
    """
		geometry_options = {
		"head": "40pt",
		"margin": "0.5in",
		"bottom": "0.6in",
		"includeheadfoot": True
		}
		doc = Document(geometry_options=geometry_options)

		## Define style of report
		reportStyle = PageStyle("reportStyle")

		with reportStyle.create(Head("R")) as left_header:
				with left_header.create(MiniPage(width=NoEscape(r"0.49\textwidth"),
				                                  pos='c', align='l')) as title_wrapper:
					title_wrapper.append(LargeText(bold("RiMEA-Projekt")))
					title_wrapper.append(LineBreak())
					title_wrapper.append(MediumText(bold("Anlyse")))

		doc.preamble.append(reportStyle)

		## Apply Pagestyle
		doc.change_document_style("reportStyle")

		## Create table
		with doc.create(LongTabu("X[c] X[c]",
		                       row_height=1.5)) as report_table:
				report_table.add_row(["Test",
				                    "evacuation time(s)"],
				                   mapper=bold)
				report_table.add_hline()

		## Write the results of 3 tests in table
		for i in range(1,4):
			report_table.add_row(i, get_evac_time(i)[0])

		doc.append(NewPage())

		doc.generate_pdf("RiMEA-Projekt Evacution Analyse", clean_tex=False)
开发者ID:JuPedSim,项目名称:jpscore,代码行数:44,代码来源:reportscript.py


注:本文中的pylatex.Document.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。