所以我在子图像中插入了这样的图像,但最后一张图片不是完整的。该怎么办?如能得到任何帮助,我将不胜感激。
\usepackage{graphicx}
\usepackage{authblk}
\usepackage{float}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{algorithm}
\usepackage{amsmath}
\begin{figure}
\centering
\begin{subfigure}[b]{0.5\textwidth}
\centering
\includegraphics[width=\textwidth]{histo1.jpg}
\caption{}
\label{fig:y equals x}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.5\textwidth}
\centering
\includegraphics[width=\textwidth]{histo2.jpg}
\caption{}
\label{fig:three sin x}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.5\textwidth}
\centering
\includegraphics[width=\textwidth]{histo3.jpg}
\caption{}
\label{fig:five over x}
\end{subfigure}
\caption{ Histogram Plot of (a) Input Image, (b) Encrypted Image and (c) Decrypted Image }
\label{fig:three graphs}
\end{figure}
答案1
你能前两张图像并排,但显然不是最后一张。
问题在于您在子图之间插入了一个空格,因此前两个子图无法放在一行中。查看%<---
空格的位置。
对于第三张图片,最好有一个段落分隔符和一些垂直空间。
\documentclass{article}
\usepackage{graphicx}
\usepackage{authblk}
\usepackage{float}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{algorithm}
\usepackage{amsmath}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{0.5\textwidth}
\centering
\includegraphics[width=\textwidth]{histo1.jpg}
\caption{}
\label{fig:y equals x}
\end{subfigure}%<---
\hfill
\begin{subfigure}[b]{0.5\textwidth}
\centering
\includegraphics[width=\textwidth]{histo2.jpg}
\caption{}
\label{fig:three sin x}
\end{subfigure}
\bigskip
\begin{subfigure}[b]{0.5\textwidth}
\centering
\includegraphics[width=\textwidth]{histo3.jpg}
\caption{}
\label{fig:five over x}
\end{subfigure}
\caption{ Histogram Plot of (a) Input Image, (b) Encrypted Image and (c) Decrypted Image }
\label{fig:three graphs}
\end{figure}
\end{document}
如果希望三张图片都在一行上,请使用文本宽度除以 3。
\documentclass{article}
\usepackage{graphicx}
\usepackage{authblk}
\usepackage{float}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{algorithm}
\usepackage{amsmath}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{0.33333\textwidth}
\centering
\includegraphics[width=\textwidth]{histo1.jpg}
\caption{}
\label{fig:y equals x}
\end{subfigure}%<---
\hfill
\begin{subfigure}[b]{0.33333\textwidth}
\centering
\includegraphics[width=\textwidth]{histo2.jpg}
\caption{}
\label{fig:three sin x}
\end{subfigure}%<---
\begin{subfigure}[b]{0.33333\textwidth}
\centering
\includegraphics[width=\textwidth]{histo3.jpg}
\caption{}
\label{fig:five over x}
\end{subfigure}
\caption{ Histogram Plot of (a) Input Image, (b) Encrypted Image and (c) Decrypted Image }
\label{fig:three graphs}
\end{figure}
\end{document}
答案2
这将\allowbreak
自动中断子图的一行,而不会在过程中占用空间。
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{algorithm}
\usepackage{amsmath}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{0.5\textwidth}
\centering
\includegraphics[width=\textwidth]{example-image-a}
\caption{}
\label{fig:y equals x}
\end{subfigure}\allowbreak
\hfill
\begin{subfigure}[b]{0.5\textwidth}
\centering
\includegraphics[width=\textwidth]{example-image-b}
\caption{}
\label{fig:three sin x}
\end{subfigure}\allowbreak
\hfill
\begin{subfigure}[b]{0.5\textwidth}
\centering
\includegraphics[width=\textwidth]{example-image-c}
\caption{}
\label{fig:five over x}
\end{subfigure}% note, \caption starts and ends with a \par
\caption{ Histogram Plot of (a) Input Image, (b) Encrypted Image and (c) Decrypted Image }
\label{fig:three graphs}
\end{figure}
\end{document}