社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

Python Latex包未插入图形

Andrew • 1 年前 • 745 次点击  

我有一个python程序,使用pdflatex-PyPDF2包生成一个LaTeX.tex文件,然后将其转换为.pdf文件。

我的问题是pdf文件需要包含一个图像,而该图像没有插入到文档中。

LaTeX文件由以下python代码生成:

# compose a LaTex file
content = r'''\documentclass{article}
\begin{document}
\usepackage{graphicx}
\graphicspath{./}
\includegraphics{Image.jpg}
\textbf{\huge DSC 501\\}
\textit{Programming for Data Science\\}
\vspace{1cm}
\textbf{Andrew Coleman\\}
19 November 2022\\
\textbf{\Large Southern Connecticut State University \\}
\section{IMDb movie analysis}
Here we are...\\

\end{document}

# specify the file name without an extension so we can reuse it

from datetime import datetime
outfile = 'scsu-dsc501-pdflatex-demo'
timestamped_outfile = data_path + outfile + '_' + datetime.now().strftime("%Y-%m-%d_at_%H-%M-%S")

# store a LaTex file
with open(timestamped_outfile+'.tex','w') as f:
    f.write(content)

当它被转换为pdf文件,而不是图像(image.jpg,与.tex文件在同一目录中)时,pdf文件包含“graphicx./image.jpg”

如何使图像本身显示在pdf中?

这是通过Colab在Mac笔记本电脑上运行的。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/158628
 
745 次点击  
文章 [ 1 ]  |  最新文章 1 年前