我已经搜索解决方案好几个小时了,包括这个论坛。也许有人可以给我指明正确的方向,这真的很令人沮丧。
基本上我想做同样的事情: 大图旁边有几张小图
我需要一页上有 7 张图片,一行 3 张,然后中间 1 张,然后一行 3 张:
xxx
_X
xxx
中间的图片非常大,我无法让它 a) 完全显示(没有错误)或 b) 显示但不能正确对齐/与其他图片重叠
当前代码:
\documentclass[landscape]{article}
\usepackage{subfigure}
\usepackage{graphicx}
\usepackage[a4paper]{geometry}
\input{setup/header.tex}
\begin{document}
\pagenumbering{gobble}
\begin{figure}[!htbp]
\centering
\fbox{\subfigure{
\subfigure{\includegraphics[scale = 0.3]{testdata.png}}
\subfigure{\includegraphics[scale = 0.3]{testdata.png}}
\subfigure{\includegraphics[scale = 0.3]{testdata.png}}
}}
\fbox{\centerline{\subfigure{\includegraphics[scale = 0.003]{testpic.png}}}}
\fbox{\subfigure{
\subfigure{\includegraphics[scale = 0.3]{testdata.png}}
\subfigure{\includegraphics[scale = 0.3]{testdata.png}}
\subfigure{\includegraphics[scale = 0.3]{testdata.png}}
}}
\end{figure}
\end{document}
当我尝试修复缩放比例或图片不再显示时,我总是会遇到一些错误。较小的图片可以正常工作。我添加了 fbox 来查看框的轮廓 - 中间的框太小了,无论我做什么,它通常都会错位。而且它是上下颠倒的 - 我甚至不介意(角度 = 180,我知道,之后对齐情况更糟)
任何帮助我都会非常感激。我手头有 150 张图片,但我不想将它们复制到 Office(计划是编写一个 python 脚本来一次性获取所有图片的 tex 代码,但为此这个 tex 代码必须有效)
编辑:此代码只是不显示图片:
\documentclass[landscape]{article}
\usepackage{graphicx}
\usepackage[a4paper]{geometry}
%\input{setup/header.tex}
\begin{document}
\begin{figure}[!htbp]
\centering
\fbox{\includegraphics[scale = 0.3]{testdata.png}
\includegraphics[scale = 0.3]{testdata.png}
\includegraphics[scale = 0.3]{testdata.png}
}
\fbox{\includegraphics[width = 4cm]{testpic.png}}
\fbox{\includegraphics[scale = 0.3]{testdata.png}
\includegraphics[scale = 0.3]{testdata.png}
\includegraphics[scale = 0.3]{testdata.png}
}
\end{figure}
\end{document}
此代码导致我出现“尺寸太大”错误:
\documentclass[landscape]{article}
\usepackage{graphicx}
\usepackage[a4paper]{geometry}
%\input{setup/header.tex}
\begin{document}
\begin{figure}[!htbp]
\centering
\fbox{\includegraphics[scale = 0.3]{testdata.png}
\includegraphics[scale = 0.3]{testdata.png}
\includegraphics[scale = 0.3]{testdata.png}
}
\fbox{\includegraphics[width = 5cm]{testpic.png}}
\fbox{\includegraphics[scale = 0.3]{testdata.png}
\includegraphics[scale = 0.3]{testdata.png}
\includegraphics[scale = 0.3]{testdata.png}
}
\end{figure}
\end{document}
答案1
我找到了解决问题的方法。感谢您提供正确的订购代码,但在这种情况下,出于某种原因,调整图片大小(即使是很小的量)也解决了“尺寸太大”的错误。我猜图片中的一些元数据把整个事情搞乱了(可能是因为它是 SEM 图片 @270k 比例?)。无论如何,现在可以正常工作了
我使用了这个调整大小工具:http://www.faststone.org/FSResizerDetail.htm
谢谢大家的帮助,否则我可能已经放弃了 :) 我可能会写一个小教程,介绍如何使用 Gnuplot 和 LaTeX 进行批量数据和图像处理。接下来是 Python 脚本,用于为所有图片 (~150) 生成 LaTeX 代码 :)
编辑:如果有人感兴趣,这是我用来生成大量 LaTeX 代码的 python 代码:
f = open('Hex06.tex', 'w')
hex = 'Hex06'
print('\n')
print('writing Hex06.tex .....\n')
for field in ['03_2h3h','03_23','04_6h5','04_36h','04_55h','06_55h','07_6h5','07_44h','07_55h','07_66h','06_6h5','07_5hh4','07_34','09_13','16_12','08_16']:
if(field == '03_2h3h'):seg = '0'
if(field == '03_23'):seg = '0'
if(field == '04_6h5'):seg = '0'
if(field == '04_36h'):seg = '0'
if(field == '04_55h'):seg = '0'
if(field == '06_55h'):seg = '0'
if(field == '07_6h5'):seg = '0'
if(field == '07_44h'):seg = '0'
if(field == '07_55h'):seg = '0'
if(field == '07_66h'):seg = '0'
if(field == '06_6h5'):seg = '1'
if(field == '07_5hh4'):seg = '1'
if(field == '07_34'):seg = '1'
if(field == '09_13'):seg = '1'
if(field == '16_12'):seg = '1'
if(field == '08_16'):seg = '2'
f.write('\n')
f.write('\\begin{figure}[!htbp]\n')
f.write('\centering\n')
f.write('\\fbox{\includegraphics[scale = 0.7]{' + hex + '/2P_UI_all-currents_' + hex + '_'+seg+'seg_field'+field+'_+15V.png}\n')
f.write(' \includegraphics[scale = 0.7]{' + hex + '/2P_UI_all-currents_' + hex + '_'+seg+'seg_field'+field+'_0V.png}\n')
f.write(' \includegraphics[scale = 0.7]{' + hex + '/2P_UI_all-currents_' + hex + '_'+seg+'seg_field'+field+'_-15V.png}\n')
f.write('}\n')
f.write('\n')
f.write('\\fbox{\includegraphics[scale = 1]{' + hex + '/SEM-pics/resized/' + hex + '-done_field'+field+'.png}\n')
f.write('\\textbf{{\Huge '+hex+' '+seg+'-Au-Segments}}}')
f.write('\n')
f.write('\\fbox{\includegraphics[scale = 0.7]{' + hex + '/2P_TR_all-currents_' + hex + '_'+seg+'seg_field'+field+'_+2V.png}\n')
f.write(' \includegraphics[scale = 0.7]{' + hex + '/2P_TR_all-currents_' + hex + '_'+seg+'seg_field'+field+'_0V.png}\n')
f.write(' \includegraphics[scale = 0.7]{' + hex + '/2P_TR_all-currents_' + hex + '_'+seg+'seg_field'+field+'_-2V.png}\n')
f.write(' }\n')
f.write('\end{figure}\n')
f.write('\\newpage\n')
f.write('\n')
f.close()
print('done with Hex06.tex, starting Hex07.tex.....\n')
f = open('Hex07.tex', 'w')
hex = 'Hex07'
for field in ['06_41','06_56','08_4h5h','08_45','11_16','14_21','14_66h','18_6h1h','06_15','09_23','18_16h','14_16']:
if(field == '06_41'):seg = '0'
if(field == '06_56'):seg = '0'
if(field == '08_4h5h'):seg = '0'
if(field == '08_45'):seg = '0'
if(field == '11_16'):seg = '0'
if(field == '14_21'):seg = '0'
if(field == '14_66h'):seg = '0'
if(field == '18_6h1h'):seg = '0'
if(field == '06_15'):seg = '1'
if(field == '09_23'):seg = '1'
if(field == '18_16h'):seg = '1'
if(field == '14_16'):seg = '2'
f.write('\n')
f.write('\\begin{figure}[!htbp]\n')
f.write('\centering\n')
f.write('\\fbox{\includegraphics[scale = 0.7]{' + hex + '/2P_UI_all-currents_' + hex + '_'+seg+'seg_field'+field+'_+15V.png}\n')
f.write(' \includegraphics[scale = 0.7]{' + hex + '/2P_UI_all-currents_' + hex + '_'+seg+'seg_field'+field+'_0V.png}\n')
f.write(' \includegraphics[scale = 0.7]{' + hex + '/2P_UI_all-currents_' + hex + '_'+seg+'seg_field'+field+'_-15V.png}\n')
f.write('}\n')
f.write('\n')
f.write('\\fbox{\includegraphics[scale = 1]{' + hex + '/SEM-pics/resized/' + hex + '_field'+field+'.png}\n')
f.write('\\textbf{{\Huge '+hex+' '+seg+'-Ni-Segments}}}')
f.write('\n')
f.write('\\fbox{\includegraphics[scale = 0.7]{' + hex + '/2P_TR_all-currents_' + hex + '_'+seg+'seg_field'+field+'_+2V.png}\n')
f.write(' \includegraphics[scale = 0.7]{' + hex + '/2P_TR_all-currents_' + hex + '_'+seg+'seg_field'+field+'_0V.png}\n')
f.write(' \includegraphics[scale = 0.7]{' + hex + '/2P_TR_all-currents_' + hex + '_'+seg+'seg_field'+field+'_-2V.png}\n')
f.write(' }\n')
f.write('\end{figure}\n')
f.write('\\newpage\n')
f.write('\n')
f.close()
print('done with Hex07.tex, starting Hex10.tex.....\n')
f = open('Hex10.tex', 'w')
hex = 'Hex10'
for field in ['01_1h2','01_6h6','01_13','01_55h','02_55h','02_66h','01_5h6h','01_21','02_6h5','02_34','04_45','05_1h3','07_61','08_4h3','08_32','09_64','12_1h6','16_63']:
if(field == '01_1h2'):seg = '0'
if(field == '01_6h6'):seg = '0'
if(field == '01_13'):seg = '0'
if(field == '01_55h'):seg = '0'
if(field == '02_55h'):seg = '0'
if(field == '02_66h'):seg = '0'
if(field == '01_5h6h'):seg = '1'
if(field == '01_21'):seg = '1'
if(field == '02_6h5'):seg = '1'
if(field == '02_34'):seg = '1'
if(field == '04_45'):seg = '1'
if(field == '05_1h3'):seg = '1'
if(field == '07_61'):seg = '1'
if(field == '08_4h3'):seg = '1'
if(field == '08_32'):seg = '1'
if(field == '09_64'):seg = '1'
if(field == '12_1h6'):seg = '1'
if(field == '16_63'):seg = '1'
f.write('\n')
f.write('\\begin{figure}[!htbp]\n')
f.write('\centering\n')
f.write('\\fbox{\includegraphics[scale = 0.7]{' + hex + '/2P_UI_all-currents_' + hex + '_'+seg+'seg_field'+field+'_+15V.png}\n')
f.write(' \includegraphics[scale = 0.7]{' + hex + '/2P_UI_all-currents_' + hex + '_'+seg+'seg_field'+field+'_0V.png}\n')
f.write(' \includegraphics[scale = 0.7]{' + hex + '/2P_UI_all-currents_' + hex + '_'+seg+'seg_field'+field+'_-15V.png}\n')
f.write('}\n')
f.write('\n')
f.write('\\fbox{\includegraphics[scale = 1]{' + hex + '/SEM-pics/resized/' + hex + '_Au-seg_field'+field+'.png}\n')
f.write('\\textbf{{\Huge '+hex+' '+seg+'-Au-Segments}}}')
f.write('\n')
f.write('\\fbox{\includegraphics[scale = 0.7]{' + hex + '/2P_TR_all-currents_' + hex + '_'+seg+'seg_field'+field+'_+2V.png}\n')
f.write(' \includegraphics[scale = 0.7]{' + hex + '/2P_TR_all-currents_' + hex + '_'+seg+'seg_field'+field+'_0V.png}\n')
f.write(' \includegraphics[scale = 0.7]{' + hex + '/2P_TR_all-currents_' + hex + '_'+seg+'seg_field'+field+'_-2V.png}\n')
f.write(' }\n')
f.write('\end{figure}\n')
f.write('\\newpage\n')
f.write('\n')
f.close()
print('done with Hex10.tex\n')
print('\n')
print('pleasure to do business with you\n')
print('see you next time\n')
print('\n')