下面我有 4 个子图,但是如果第三个子图文本超过一行,我就会遇到一个问题,第 4 个图会向下移动一点,如下所示。不知道如何解决这个问题?
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
% The preceding line is only needed to identify funding in the first footnote. If that is unneeded, please comment it out.
\usepackage{cite}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage{tabularx}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\title{AlgorithmTemplate}
% \documentclass[12pt]{article}
\usepackage{fullpage}
\usepackage{times}
\usepackage{fancyhdr}
\usepackage[ruled,vlined]{algorithm2e}
\include{pythonlisting}
\begin{document}
sa
\begin{figure}
\centering
\begin{subfigure}[b]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{testfig.png}
\caption{a}
\label{fig: a}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{testfig.png}
\caption{b }
\label{fig:b}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{testfig.png}
\caption{I have some text here that will shift the 4th figure to bottom}
\label{fig:c}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{testfig.png}
\caption{d}
\label{fig:d}
\end{subfigure}
\caption{d}
\label{fig:three graphs}
\end{figure}
\end{document}
答案1
将每个 的底部对齐方式更改[b]
为顶部对齐方式。然后,如果您想要一个 4x4 图像网格,请删除中间并添加一个空白区域。这会将其他 2 个数字移动到下一行。您可能需要增加垂直间距。因此,使用任意长度 sa等或。[t]
\subfigure
\hfill
\vspace{...}
12pt
1cm
\bigskip
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
% The preceding line is only needed to identify funding in the first footnote. If that is unneeded, please comment it out.
\usepackage{cite}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage{tabularx}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\title{AlgorithmTemplate}
% \documentclass[12pt]{article}
\usepackage{fullpage}
\usepackage{times}
\usepackage{fancyhdr}
\usepackage[ruled,vlined]{algorithm2e}
\include{pythonlisting}
\usepackage{kantlipsum}
\begin{document}
\kant[1]
\begin{figure}[tbh]
\centering
\begin{subfigure}[t]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image}
\caption{a}
\label{fig: a}
\end{subfigure}%
\hfill%
\begin{subfigure}[t]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image}
\caption{b }
\label{fig:b}
\end{subfigure}
\bigskip%
\begin{subfigure}[t]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image}
\caption{I have some text here that will shift the 4th figure to bottom}
\label{fig:c}
\end{subfigure}%
\hfill%
\begin{subfigure}[t]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image}
\caption{d}
\label{fig:d}
\end{subfigure}
\caption{Main}
\label{fig:three graphs}
\end{figure}
\kant[2-4]
\end{document}