我想让两张图片并排居中,垂直居中对齐,标题在底部。我设法做了所有事情,除了将它们居中。以下是图片:
这是我的代码:
\usepackage{caption,floatrow}
\DeclareCaptionSubType[alph]{figure}
\captionsetup[figure]{labelsep=colon}
\captionsetup[subfigure]{labelformat=brace,labelsep=space,labelfont=bf}
\floatsetup[subfigure]{capposition=bottom,heightadjust=object,valign=c}
\begin{document}
\begin{figure}[ht]
\ffigbox[\hsize]
{\begin{subfloatrow}
\ffigbox
{\includegraphics[height=.6\hsize]{radar.png}}
{\caption{Feature radar}\label{fig:radar}}
\ffigbox
{\includegraphics[height=1.2\hsize]{map.png}}
{\caption{Map}\label{fig:map}}
\end{subfloatrow}}
{\caption{Set plot}}
\end{figure}
\end{document}
在此之前:
\documentclass{article}
\usepackage{verbatim}
\usepackage{lipsum}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{graphicx,url}
\graphicspath{ {./Figures/} }
\usepackage{subcaption}
\usepackage{flushend}
\usepackage{xspace} % for new command space
\usepackage{hyperref} % alternatively use url
\usepackage{tikz}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{systeme}
\usepackage[ruled,vlined]{algorithm2e}
\usepackage[export]{adjustbox}% http://ctan.org/pkg/adjustbox | align figures
\usepackage{caption,floatrow}
答案1
另一种方法是
- 将第一个(也较短)图形的垂直对齐调整到其中心(使用包
align=c
中的选项graphbox
),然后 - 插入一个垂直居中的零宽度框,其高度为第二个(也更高)的图形。
\documentclass{article}
\usepackage{graphbox} % it depends on "graphicx" package
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\subcaptionbox{A cat\label{cat}}
{%
\includegraphics[width=3cm,align=c]{example-image}%
\vphantom{\includegraphics[width=6cm,align=c]{example-image}}%
}\qquad
\subcaptionbox{An elephant\label{elephant}}
{\includegraphics[width=6cm]{example-image}}
\caption{Two animals}\label{animals}
\end{figure}
\end{document}
答案2
以下是我如何让它发挥作用的:
\begin{figure}[ht]
\centering
\ffigbox[\hsize]
{\begin{subfloatrow}
\ffigbox[.5\hsize]
{\includegraphics[width=\FBwidth]{radar.png}}
{\caption{Feature radar}\label{fig:radar}}
\ffigbox[1.4\hsize]
{\includegraphics[width=\FBwidth]{map.png}}
{\caption{Map}\label{fig:map}}
\end{subfloatrow}}
{\caption{Set plot}}
\end{figure}