我正在尝试对齐 3 列 x 2 行的图形网格,其中顶行与顶部对齐,底行与底部对齐。我将子图定义为列,以便标题编号遵循我想要的惯例(即 a 在 b 之上,c 在 d 之上......)。我尝试对子图使用对齐参数,以及在子图之间乱搞,\vfill
以\vspace*{\fill}
尝试延长图形之间的垂直间距以进行对齐,但无济于事。
我目前得到了这个结果:
\documentclass[sigplan,anonymous,review,10pt]{acmart}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure*}[htbp]
\centering
\begin{subfigure}{0.33\textwidth} % a, b
\centering
\begin{subfigure}[t]{\linewidth} % a
\begin{lstlisting}
Code snippet 1
\end{lstlisting}
\caption{}
\label{code1}
\end{subfigure}
\begin{subfigure}[b]{\linewidth} % b
\includegraphics[height=3cm]{example-image-a}
\caption{}
\label{fig1}
\end{subfigure}
\end{subfigure}
%===============================
% New Column for C & D
%===============================
\begin{subfigure}{0.33\textwidth} % c, d
\begin{subfigure}[t]{\linewidth} % c
\centering
\begin{lstlisting}
Code snippet
2
\end{lstlisting}
\caption{}
\label{code2}
\end{subfigure}
\begin{subfigure}[b]{\linewidth} % d
\centering
\includegraphics[height=4cm]{example-image-b}
\caption{}
\label{fig2}
\end{subfigure}
\end{subfigure}
%===============================
% New column for E & F
%===============================
\begin{subfigure}{0.33\textwidth} % e, f
\centering
\begin{subfigure}[b]{\linewidth} % e
\centering
\begin{lstlisting}
Code
snippet
3
\end{lstlisting}
\caption{}
\label{code3}
\end{subfigure}
\begin{subfigure}[b]{\linewidth} % f
\centering
\includegraphics[height=5cm]{example-image-c}
\caption{}
\label{fig3}
\end{subfigure}
\end{subfigure}
\caption[]{Caption}
\label{label}
\end{figure*}
\end{document}
我想要的是:
答案1
解决方案在于将子图保持为行(以便于对齐),并使用命令addtocounter
手动调整子图的编号。
\documentclass[sigplan,anonymous,review,10pt]{acmart}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure*}[htbp]
\centering
\begin{subfigure}[b]{\textwidth}
\centering
\begin{subfigure}[b]{0.33\linewidth}
\centering
\begin{lstlisting}
Code snippet 1
\end{lstlisting}
\caption{}
\label{code1}
\end{subfigure}
\begin{subfigure}[b]{0.33\linewidth}
\addtocounter{subfigure}{1}
\centering
\begin{lstlisting}
Code snippet
2
\end{lstlisting}
\caption{}
\label{code2}
\end{subfigure}
\begin{subfigure}[b]{0.33\linewidth}
\addtocounter{subfigure}{1}
\centering
\begin{lstlisting}
Code
snippet
3
\end{lstlisting}
\caption{}
\label{code3}
\end{subfigure}
\end{subfigure}
\begin{subfigure}[b]{\textwidth}
\centering
\begin{subfigure}[b]{0.33\linewidth}
\addtocounter{subfigure}{-4}
\centering
\includegraphics[height=3cm]{example-image-a}
\caption{}
\label{fig1}
\end{subfigure}
\begin{subfigure}[b]{0.33\linewidth}
\addtocounter{subfigure}{1}
\centering
\includegraphics[height=4cm]{example-image-b}
\caption{}
\label{fig2}
\end{subfigure}
\begin{subfigure}[b]{0.33\linewidth}
\addtocounter{subfigure}{1}
\centering
\includegraphics[height=5cm]{example-image-c}
\caption{}
\label{fig3}
\end{subfigure}
\end{subfigure}
\caption[]{Caption}
\label{label}
\end{figure*}
\end{document}