我在 中使用了 envlstlisting
和。由于空间不足,我想将图像 B 放在图像 A 之上,并为其添加自己的标题。我还会保留通用标题。有什么建议吗?subfigure
figure
\documentclass[11pt]{article}
\usepackage{listings}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}[h!]
\noindent\begin{subfigure}[b]{0.3\textwidth}
\begin{lstlisting}[]
while(a<0){
a++;
long code
...
...
...
}
\end{lstlisting}
\caption{listing 1}
\end{subfigure}%
\noindent\begin{subfigure}[b]{0.45\textwidth}
\begin{align*}
&F_1(a, b) \\
&F_2(a, b) \\
&F_1(a, b) \\
&F_2(a, b) \\
\end{align*}
\caption{eqation 2}
\end{subfigure}%
\noindent\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[scale=0.2]{example-image-a}
\caption{image 1}
\end{subfigure}%
\noindent\begin{subfigure}[t]{0.3\textwidth}
\includegraphics[scale=0.2]{example-image-b}
\caption{image 1}
\end{subfigure}
\caption{general caption}
\end{figure}
\end{document}
目前结果是:
答案1
像这样?
您可以在同一张图片中插入两张图片,subfigure
后面跟着标题,但必须在它们之间插入一个空行:
\documentclass[11pt]{article}
\usepackage{listings}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[skip=0.25ex,belowskip=1ex]{subcaption}
\begin{document}
\begin{figure}[ht]
\noindent\begin{subfigure}[b]{0.3\textwidth}
\begin{lstlisting}[]
while(a<0){
a++;
long code
...
...
...
}
\end{lstlisting}
\caption{listing 1}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.3\textwidth}
\begin{align*}
&F_1(a, b) \\
&F_2(a, b) \\
&F_1(a, b) \\
&F_2(a, b) \\
\end{align*}
\caption{eqation 2}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.2\textwidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{image 1}
\includegraphics[width=\linewidth]{example-image-b}
\caption{image 2}
\end{subfigure}
\caption{general caption}
\end{figure}
\end{document}