我正在尝试使用 python 包自动生成包含多个图像文件的图形。
我的输出看起来还不错,只是图片以单列形式输出,而如果我直接在 latex 中编写相同的代码,则输出结果为两列。有人能告诉我如何让 python 版本以双列形式输出图片吗?
这是我的代码:
\documentclass{article}
\usepackage{graphicx,python}
\begin{document}
\begin{figure}
\begin{python}
import os
directory = "."
extension = ".png"
files = [file for file in os.listdir(r'D:\New folder\Sean Read\visualisation examples\normalised cross sections\NC04\Axial') if file.lower().endswith("png")]
name=[]
for file in files:
fileName, fileExtension = os.path.splitext(file)
name.append(fileName)
for file in name:
print(r'\includegraphics[width=0.4\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/%s"}' % file)
\end{python}
\end{figure}
\end{document}
python 循环输出
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/10acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/11acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/1acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/2acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/3acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/4acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/5acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/6acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/7acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/8acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/9acs copy"}
如果我取出 python 输出并将其插入到 latex 中,则输出是双列:
\documentclass{article}
\usepackage{graphicx,python}
\begin{document}
\begin{figure}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/10acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/11acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/1acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/2acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/3acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/4acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/5acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/6acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/7acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/8acs copy"}
\includegraphics[width=0.5\textwidth]{"D:/New folder/Sean Read/visualisation examples/normalised cross sections/NC04/Axial/9acs copy"}
\end{figure}
\end{document}
有什么建议么?