images to latex

发布于 2023-11-24  268 次阅读


Please refresh the page if equations are not rendered correctly.
---------------------------------------------------------------

将指定目录的所有图片加入latex。

借助了PyLaTeX包。

import os

import numpy as np
from pylatex import ( Document, Figure,
                     Section)
from pylatex.utils import italic
import polykriging as pk

if __name__ == '__main__':
    path = "./../resource/images/"
    image_filenames = pk.filenames(path, ".png")

    geometry_options = {"tmargin": "1cm", "lmargin": "2cm"}
    doc = Document(geometry_options=geometry_options)

    with doc.create(Section('Pictures')):
        for image_filename in image_filenames:
            with doc.create(Figure(position='htb')) as pic:
                pic.add_image(os.path.join(path, image_filename), width='16cm')
                # pic.add_caption(image_filename[10:-13])  # hour-minutes-seconds + picture name

    # doc.generate_pdf('full', clean_tex=False)
Everything not saved will be lost.
最后更新于 2023-11-24