我有 6 个图形,我想用不同的标签绘制它们,标题相同。我尝试了两种绘图代码,但不起作用。
代碼:
\begin{figure}[htp]
\centering
\includegraphics[width=30mm]{C:/Thesis/Latex/thesis_1(1)/Figures/25_for.jpeg} \\
\subfloat b) \includegraphics[width=80mm]{C:/Thesis/Latex/thesis_1(1)/Figures/28_for.jpeg} \\
\subfloat c) \includegraphics[width=80mm]{C:/Thesis/Latex/thesis_1(1)/Figures/29_for.jpeg} \\
\subfloat d) \includegraphics[width=80mm]{C:/Thesis/Latex/thesis_1(1)/Figures/31_for.jpeg} \\
\subfloat e) \includegraphics[width=80mm]{C:/Thesis/Latex/thesis_1(1)/Figures/32_for.jpeg} \\
\subfloat f) \includegraphics[width=80mm]{C:/Thesis/Latex/thesis_1(1)/Figures/ob_for.jpeg} \\
\rule{35em}{0.3pt}
\caption{Patterns of Wireless sensor networks with respect to the MetoSwiss Forecasts for $2007-09-30$}
\label{fig: pattern30}
\end{figure}
和 :
\begin{figure}[htp]
\centering
\includegraphics[width=80mm]{C:/Thesis/Latex/thesis_1(1)/Figures/25_for.jpeg}
\includegraphics[width=80mm]{C:/Thesis/Latex/thesis_1(1)/Figures/28_for.jpeg}
\\
\includegraphics[width=80mm]{C:/Thesis/Latex/thesis_1(1)/Figures/29_for.jpeg}
\includegraphics[width=80mm]{C:/Thesis/Latex/thesis_1(1)/Figures/31_for.jpeg}
\\
\includegraphics[width=80mm]{C:/Thesis/Latex/thesis_1(1)/Figures/32_for.jpeg}
\includegraphics[width=80mm]{C:/Thesis/Latex/thesis_1(1)/Figures/ob_for.jpeg}
\rule{35em}{0.3pt}
\caption{Patterns of Wireless sensor networks with respect to the MetoSwiss Forecasts for $2007-09-30$}
\label{fig: pattern29}
\end{figure}
答案1
另一个选择是使用subfig
包:
\documentclass{article}
\usepackage[demo]{graphicx} %5 Remove demo in your file
\usepackage{subfig}
\graphicspath{{C:/Thesis/Latex/thesis_1(1)/Figures/}}
\begin{document}
\begin{figure}[htp]
\centering
\subfloat[]{%
\includegraphics[width=.48\textwidth]{{25_for}.jpg}
\label{fig:sub1}
}%
\hfill
\subfloat[]{%
\includegraphics[width=.48\textwidth]{{28_for}.jpg}
\label{fig:sub2}
}\\
\subfloat[]{%
\includegraphics[width=.48\textwidth]{{29_for}.jpg}
\label{fig:sub3}
}%
\hfill
\subfloat[]{%
\includegraphics[width=.48\textwidth]{{31_for}.jpg}
\label{fig:sub4}
}\\
\subfloat[]{%
\includegraphics[width=.48\textwidth]{{32_for}.jpg}
\label{fig:sub5}
}%
\hfill
\subfloat[]{%
\includegraphics[width=.48\textwidth]{{ob_for}.jpg}
\label{fig:sub6}
}
\caption{Patterns of Wireless sensor networks with respect to the MetoSwiss Forecasts for $2007-09-30$}
\label{fig:pattern29}
\end{figure}
\end{document}
顺便提一下,underscore
在图片文件名中使用它并不好。如果需要,请尝试用hyphens
(-) 替换它们,例如25-for.jpeg
。正如 Op 发现的那样,问题出在扩展名上,.jpeg
而不是.jpg
答案2
我会用subcaption
及其subfigure
环境。
另外,您不必每次都指定完整的目录路径,只需使用
\graphicspath{{C:/Thesis/Latex/thesis_1(1)/Figures/}}
详情见graphicx
文档。
如果该目录仅包含.jpeg
文件,则无需在图像上使用扩展名。
要获取以下代码中的图像,请demo
从中删除选项graphicx
,即\usepackage{graphicx}
完成 MWE:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\graphicspath{{C:/Thesis/Latex/thesis_1(1)/Figures/}}
\begin{document}
\begin{figure}[htp]
\centering
\begin{subfigure}{80mm}
\includegraphics[width=\textwidth]{25_for.jpeg}
\caption{}
\end{subfigure}%
\begin{subfigure}{80mm}
\includegraphics[width=\textwidth]{28_for.jpeg}
\caption{}
\end{subfigure}%
\\
\begin{subfigure}{80mm}
\includegraphics[width=\textwidth]{29_for.jpeg}
\caption{}
\end{subfigure}%
\begin{subfigure}{80mm}
\includegraphics[width=\textwidth]{31_for.jpeg}
\caption{}
\end{subfigure}
\\
\begin{subfigure}{80mm}
\includegraphics[width=\textwidth]{32_for.jpeg}
\caption{}
\end{subfigure}%
\begin{subfigure}{80mm}
\includegraphics[width=\textwidth]{ob_for.jpeg}
\caption{}
\end{subfigure}%
\caption{Patterns of Wireless sensor networks with respect to the MetoSwiss Forecasts for $2007-09-30$}
\label{fig:pattern29}
\end{figure}
\end{document}