我可以使用以下代码片段来获得 2x2 的数字数组:
\begin{figure*}
\centering
\subfloat[f1]{%
{\includegraphics[width=0.5\textwidth]{./figures/f1.pdf}}
}%
\subfloat[f2]{%
{\includegraphics[width=0.5\textwidth]{./figures/f2.pdf}}
}%
\qquad
\subfloat[f3]{%
{\includegraphics[width=0.5\textwidth]{./figures/f3.pdf}}
}%
\subfloat[f4]{%
{\includegraphics[width=0.5\textwidth]{./figures/f4.pdf}}
}%
\caption[layout]{layout}%
\label{fig:layout}%
\end{figure*}
但是,如果我想在这 4 个图形的右侧添加另一个图形,如下图所示,我不知道该怎么做。
到目前为止我尝试过:
\begin{figure*}
\centering
\subfloat{
\subfloat[f1]{%
{\includegraphics[width=0.5\textwidth]{./figures/f1.pdf}}
}%
\subfloat[f2]{%
{\includegraphics[width=0.5\textwidth]{./figures/f2.pdf}}
}%
\qquad
\subfloat[f3]{%
{\includegraphics[width=0.5\textwidth]{./figures/f3.pdf}}
}%
\subfloat[f4]{%
{\includegraphics[width=0.5\textwidth]{./figures/f4.pdf}}
}%
}
\subfloat[f5]{%
{\includegraphics[width=0.5\textwidth]{./figures/f5.pdf}}
\caption[layout]{layout}%
\label{fig:layout}%
\end{figure*}
但结果并不如我所料。
有人知道对此的一个简单修改吗?
答案1
一种可能性是使用tabular
它来更好地控制行和列的内容。(第一个例子)。它需要调整第一行的位置以对齐图形的顶部。
第二种选择是使用该nicematrix
包并使用命令\Block
定义一个单元格块(这里是 2 行、1 列)并将内容居中,而无需进行额外的设置。
还有minipages
leandriis 所建议的选项。
所有这些都很容易推广。
\documentclass{article}
\usepackage{caption}
\usepackage{nicematrix}
%% The example images are provided by the graphicx package, which is loaded by nicematrix
%\usepackage{graphicx}
\begin{document}
\begin{table}
\begin{tabular}{ccc}
\includegraphics[width=0.3\textwidth, height=0.3\linewidth]{example-image-a} &
\includegraphics[width=0.3\textwidth, height=0.3\linewidth ]{example-image-a} &\\[-0.31\linewidth] %adjust to level the tops
\includegraphics[width=0.3\textwidth, height=0.3\linewidth]{example-image-b} &
\includegraphics[width=0.3\textwidth, height=0.3\linewidth]{example-image-b} &
\includegraphics[width=0.3\textwidth, height=0.61\linewidth]{example-image-c}
\end{tabular}
\caption[layout]{layout with tabular}%
\label{fig:layout1}%
\end{table}
\vspace{50pt}
\begin{table}
\begin{NiceTabular}{ccc}
\includegraphics[width=0.3\textwidth, height=0.3\linewidth]{example-image-a} &
\includegraphics[width=0.3\textwidth, height=0.3\linewidth ]{example-image-a} &
\Block{2-1}{\includegraphics[width=0.3\textwidth, height=0.61\linewidth]{example-image-c}} \\
\includegraphics[width=0.3\textwidth, height=0.3\linewidth]{example-image-b} &
\includegraphics[width=0.3\textwidth, height=0.3\linewidth]{example-image-b} &
\end{NiceTabular}
\caption[layout]{layout with nicematrix}%
\label{fig:layout2}%
\end{table}
\end{document}