from string import Template cmp_template = Template( r"""\begin{figure}[H] \centering \begin{subfigure}{\linewidth} \begin{minipage}{0.12\linewidth}\centering\caption*{原模型 500}\end{minipage} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./comparison/${name}_000_500_0.png} \end{minipage} \begin{minipage}{0.17\linewidth} \includegraphics[width=\linewidth]{${name}.png} \end{minipage} \end{subfigure} \begin{subfigure}{\linewidth} \hspace{5.2em} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./comparison/${name}_000_500_1.png} \end{minipage} \end{subfigure} \begin{subfigure}{\linewidth} \begin{minipage}{0.12\linewidth}\centering\caption*{原模型 1000}\end{minipage} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./comparison/${name}_000_1000_0.png} \end{minipage} \end{subfigure} \vspace{1em} \begin{subfigure}{\linewidth} \hspace{5.2em} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./comparison/${name}_000_1000_1.png} \end{minipage} \end{subfigure} \begin{subfigure}{\linewidth} \begin{minipage}{0.12\linewidth}\centering\caption*{改进模型 500}\end{minipage} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./comparison/${name}_111_500_0.png} \end{minipage} \end{subfigure} \begin{subfigure}{\linewidth} \hspace{5.2em} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./comparison/${name}_111_500_1.png} \end{minipage} \end{subfigure} \begin{subfigure}{\linewidth} \begin{minipage}{0.12\linewidth}\centering\caption*{改进模型 1000}\end{minipage} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./comparison/${name}_111_1000_0.png} \end{minipage} \end{subfigure} \begin{subfigure}{\linewidth} \hspace{5.2em} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./comparison/${name}_111_1000_1.png} \end{minipage} \end{subfigure} \end{figure}""") abl_template = Template( r"""\begin{figure}[H] \centering \begin{subfigure}{\linewidth} \begin{minipage}{0.12\linewidth}\centering\caption*{改进模型 \\ vgg19 \\ resnext \\ gram}\end{minipage} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./ablation/abl_${name}_111_0.png} \end{minipage} \begin{minipage}{0.17\linewidth} \includegraphics[width=\linewidth]{${name}.png} \end{minipage} \end{subfigure} \vspace{1em} \begin{subfigure}{\linewidth} \hspace{5.2em} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./ablation/abl_${name}_111_1.png} \end{minipage} \end{subfigure} \begin{subfigure}{\linewidth} \begin{minipage}{0.12\linewidth}\centering\caption*{vgg16 \\ resnext \\ gram}\end{minipage} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./ablation/abl_${name}_011_0.png} \end{minipage} \end{subfigure} \begin{subfigure}{\linewidth} \hspace{5.2em} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./ablation/abl_${name}_011_1.png} \end{minipage} \end{subfigure} \begin{subfigure}{\linewidth} \begin{minipage}{0.12\linewidth}\centering\caption*{vgg19 \\ resnet \\ gram}\end{minipage} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./ablation/abl_${name}_101_0.png} \end{minipage} \end{subfigure} \begin{subfigure}{\linewidth} \hspace{5.2em} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./ablation/abl_${name}_101_1.png} \end{minipage} \end{subfigure} \begin{subfigure}{\linewidth} \begin{minipage}{0.12\linewidth}\centering\caption*{vgg19 \\ resnext \\ mse}\end{minipage} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./ablation/abl_${name}_110_0.png} \end{minipage} \end{subfigure} \begin{subfigure}{\linewidth} \hspace{5.2em} \begin{minipage}{0.68\linewidth} \centering \includegraphics[width=\linewidth]{./ablation/abl_${name}_110_1.png} \end{minipage} \end{subfigure} \end{figure}""") res = '' lst = ['18993', '29052', '30925', '78717', 'mosaic', 'pearl', 'picasso', 'star'] type = 'abl' if type == 'cmp': for name in lst: res += cmp_template.substitute(name=name) + '\n\n' elif type == 'abl': for name in lst: res += abl_template.substitute(name=name) + '\n\n' print(res)