我有一个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笔记本电脑上运行的。