![数组中的子图](https://linux22.com/image/283413/%E6%95%B0%E7%BB%84%E4%B8%AD%E7%9A%84%E5%AD%90%E5%9B%BE.png)
如何使用具有此对齐的子图创建图形?:
|figure 1 | figure 3 | figure 4 |
|figure 2 | | |
请注意,我希望图 3 位于两行中,图 4 也位于两行中。我已经看到该multirow
包是必需的,但是如果我使用它,我会得到错误的顺序(水平而不是垂直)。有没有办法绕过这个问题?
这是对此问题的后续问题: 如何将子图放在多行中
请注意,解决方案本质上是相同的,但我无法标记子图的顺序。
编辑:代码似乎以这种方式工作! *我正在使用 subfigure 包。
\begin{figure}[t]
\setlength{\abovecaptionskip}{-5pt}
\setlength{\belowcaptionskip}{-5pt}
\addtolength{\subfigcapskip}{3pt}
\centering
\begin{tabular}{ccc}
\subfigure[car image pair]{\includegraphics[scale=0.17]{car_example.jpg}
\label{fig:img_pair_1}} &
\multirow{-4}[2.5]{*}{\subfigure[car image set]{\includegraphics[scale=0.136]{car_total.jpg}
\label{fig:img_complete_1}}} &
\multirow{-4}[2.5]{*}{\subfigure[animal image set]{\includegraphics[scale=0.136]{aww_total.jpg}
\label{fig:img_complete_2}}} \\
\subfigure[animal image pair]{\includegraphics[scale=0.17]{aww_example.jpg}
\label{fig:img_pair_2}}\\
\end{tabular}
\vspace{10pt}
\caption[]{Caption}
\label{fig:affinity}
\vspace{-10pt}
\end{figure}
答案1
您可以使用 或 或 相应地修改链接问题中的答案minipage
。tabular
我tabularx
使用过minipage
:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure}
\begin{minipage}[b][6cm]{0.3\linewidth}
\subfloat[A]{\includegraphics[width=3cm,height=2cm]{logo}}
\vfill
\subfloat[B]{\includegraphics[width=3cm,height=2cm]{logo}}
\end{minipage}%
\begin{minipage}[t][6cm]{0.3\linewidth}
\subfloat[D]{\includegraphics[width=3cm,height=6cm]{logo}}
\end{minipage}%
\begin{minipage}[t][6cm]{0.3\linewidth}
\subfloat[D]{\includegraphics[width=3cm,height=6cm]{logo}}
\end{minipage}
\caption{Many figures}\label{foo}
\end{figure}
\end{document}
答案2
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{floatrow}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\ffigbox[][7.8cm]{%
\begin{subfloatrow}
\hsize0.54\hsize
\vbox to 6.35cm{%
\ffigbox[\FBwidth]
{\caption{subfigure-a}}
{\includegraphics[width=3cm,height=2cm]{smallpicture1}}\vss
\ffigbox[\FBwidth]
{\caption{subfigure-b}}
{\includegraphics[width=3cm,height=2cm]{smallpicture2}}
}%
\end{subfloatrow}
\begin{subfloatrow}
\ffigbox[\FBwidth][]
{\caption{subfigure-c}}
{\includegraphics[width=3cm,height=6cm]{bigpicture1}}
\ffigbox[\FBwidth][]
{\caption{subfigure-d}}
{\includegraphics[width=3cm,height=6cm]{bigpicture2}}
\end{subfloatrow}\hspace*{\columnsep}%
}{\caption{four subfigures}}
\end{figure}
\end{document}
根据您的图形的实际大小,您可能需要首先调整设置subfloatrow
。
选项demo
graphicx
用黑色矩形替换实际图形;不是在实际文档中使用该选项。
答案3
使用封装和虚拟框架的替代方案varwidth
,以实现 OP 给出的所需布局。
代码
\documentclass{article}
\usepackage{subfigure}
\usepackage{varwidth,xcolor}
\usepackage[demo]{graphicx}
\usepackage[margin=1cm]{geometry}
\begin{document}
\begin{figure}[!h]
\centering
\begin{varwidth}{0.5\linewidth} % this is a must
\subfigure[Frame 1]{\includegraphics[width=4cm]{im1.png}}\\
\subfigure[Frame 2]{\includegraphics[width=4cm]{im2.png}}
\end{varwidth}
\begin{varwidth}{0.5\linewidth} % this is a must
\subfigure[Frame 3]{\includegraphics[width=4cm]{im1.png}}
\subfigure[Frame 4]{\includegraphics[width=4cm]{im2.png}}\\
\color{white}
\subfigure[Dummy Frame]{\includegraphics[draft,width=4cm]{dummy}}
\color{black}
\end{varwidth}
\caption{caption.}
\label{farraypicture}
\end{figure}
\end{document}
编辑:由于软件包已贬值,Harish Kumar 建议在此subcaption
使用caption
软件包。
这是上图的代码。(同时显示了subcaptonbox
命令和环境。)subfigure
\documentclass{article}
\usepackage{subcaption}
\usepackage{caption}
\usepackage{varwidth,xcolor}
\usepackage[demo]{graphicx}
\usepackage[margin=1cm]{geometry}
\captionsetup[figure]{labelfont=it,textfont={bf,it},labelsep=none}
\renewcommand{\thesubfigure}{(\alph{subfigure})~}
\renewcommand{\thefigure}{\arabic{figure}: }
\begin{document}
Use of subfloat command
\begin{figure}[!h]
\centering
\begin{varwidth}{0.33\linewidth} % this is a must
\subcaptionbox{Frame 1}{\includegraphics[width=4cm]{im1.png}}
\subcaptionbox{Frame 2}{\includegraphics[width=4cm]{im2.png}}\\
\end{varwidth}\quad\quad
\begin{varwidth}{0.66\linewidth} % this is a must
\subcaptionbox{Frame 3}{\includegraphics[width=4cm]{im3.png}}\quad\quad
\subcaptionbox{Frame 4}{\includegraphics[width=4cm]{im4.png}}\\
\begin{subfigure}{1in}
\color{white}
\includegraphics[width=1in]{dummy}
\caption*{}
\color{black}
\end{subfigure}
\end{varwidth}
\caption{caption}
\label{arraypicture}
\end{figure}
Use of subfigure environment
\begin{figure}[!h]
\centering
\begin{varwidth}{0.33\linewidth} % this is a must
\begin{subfigure}{4cm}
\includegraphics[width=4cm]{im1.png}
\caption{Frame 1}
\end{subfigure}\\
\begin{subfigure}{4cm}
{\includegraphics[width=4cm]{im2.png}}
\caption{Frame 2}
\end{subfigure}
\end{varwidth}\quad\quad
\begin{varwidth}{0.66\linewidth} % this is a must
\begin{subfigure}{4cm}
\includegraphics[width=4cm]{im3.png}
\caption{Frame 3}
\end{subfigure}\quad\quad
\begin{subfigure}{4cm}
{\includegraphics[width=4cm]{im4.png}}
\caption{Frame 4}
\end{subfigure}\\
\begin{subfigure}{1in}
\color{white}
\includegraphics[width=1in]{dummy}
\caption*{}
\color{black}
\end{subfigure}
\end{varwidth}
\caption{caption}
\label{arraypicture}
\end{figure}
\end{document}