如何使子图居中对齐,并使标题底部对齐?

如何使子图居中对齐,并使标题底部对齐?

我怎样才能将两个子图居中对齐,并像这样对齐两个图的标题 (a)、(b)?
假设图像大小未知。(或者我可能可以手动输入)
我看过一些与此相关的先前帖子,但他们使用了小页面,我无法成功将其应用于我的子图。

在此处输入图片描述

\documentclass[journal]{IEEEtran}
\usepackage[]{subfig}
\usepackage{stfloats}
\usepackage{float}
\usepackage{graphicx}


\begin{document}
%
\begin{figure*}[!t]
\centering
\subfloat[]{\includegraphics[width=0.25\linewidth, height=30pt]{example-image-a}
\label{fig_first_case}}
\hfil
\subfloat[]{\includegraphics[width=0.25\linewidth, height=60pt]{example-image-b}
\label{fig_second_case}}
\caption{Example of two figures. (a) The first figure. (b) The second figure}
\label{fig_subfig}
\end{figure*}
%
\end{document}

答案1

您应该subfig使用该caption=false选项进行调用,否则标题样式IEEEtran将被覆盖:这会惹恼您提交的期刊的编辑(并且可能会导致拒绝)。

对于只有一种情况,您可以手动执行此操作:

\documentclass[journal]{IEEEtran}
\usepackage[caption=false]{subfig}
\usepackage{graphicx}

\MakeRobust{\subref}

\newsavebox{\leftimage}
\newsavebox{\rightimage}
\newlength{\imageheight}
\newcommand{\placeimage}[1]{%
  \raisebox{\dimexpr(\imageheight-\height)/2}{\usebox{#1}}%
}

\begin{document}

\begin{figure*}[!t]
\centering

\sbox{\leftimage}{\includegraphics[width=0.25\linewidth, height=30pt]{example-image-a}}
\sbox{\rightimage}{\includegraphics[width=0.25\linewidth, height=60pt]{example-image-b}}

\setlength{\imageheight}{\ht\leftimage}
\ifdim\ht\rightimage>\imageheight
  \setlength{\imageheight}{\ht\rightimage}
\fi

\subfloat[]{\placeimage{\leftimage}\label{fig_first_case}}\hfil
\subfloat[]{\placeimage{\rightimage}\label{fig_second_case}}

\caption{%
  Example of two figures.
  \subref{fig_first_case}~The first figure.
  \subref{fig_second_case}~The second figure.
}
\label{fig_subfig}
\end{figure*}

\end{document}

在此处输入图片描述

测量两幅图像并确定较大的垂直尺寸。然后将装有图像的盒子升高适当的量。

答案2

有了这个包,这很容易floatrow

    \documentclass[journal]{IEEEtran}
    \usepackage[]{subfig}
    \usepackage{stfloats}
    \usepackage{graphicx}
    \usepackage{floatrow}

    \begin{document}

    \begin{figure*}[!t]
    \floatsetup{heightadjust=all, valign=c}
    \centering
    \ffigbox{\begin{subfloatrow}
    \ffigbox{\caption{}\label{fig_first_case}}{\includegraphics[width=0.25\linewidth, height=30pt]{example-image-a}
    }
    \hfil
    \ffigbox{\caption{}\label{fig_second_case}}{\includegraphics[width=0.25\linewidth, height=60pt]{example-image-b}
    }
    \end{subfloatrow}}{\caption{Example of two figures. (a) The first figure. (b) The second figure}}
    \end{figure*}

    \end{document} 

在此处输入图片描述

答案3

如果 IEEE 遇到 floatrow 问题......

\subfloat棘手的 ibt 是匹配(NOT\abovecaptionskip或)使用的间距\belowcaptionskip

\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{subfig}% for \thesubfigure

\begin{document}
%
\begin{figure*}[!t]
\centering
\tabcolsep=0.0833\linewidth% 0.5\linewidth / 6 (3 equal gaps)
\belowcaptionskip=-\baselineskip
\begin{tabular}{@{}cc@{}}
\raisebox{-0.5\height}{\includegraphics[width=0.25\linewidth, height=30pt]{example-image-a}} &
\raisebox{-0.5\height}{\includegraphics[width=0.25\linewidth, height=60pt]{example-image-b}} \\
\refstepcounter{subfigure}\label{fig_first_case}\raisebox{-1ex}{(\thesubfigure)} &
\refstepcounter{subfigure}\label{fig_second_case}\raisebox{-1ex}{(\thesubfigure)}
\end{tabular}

\caption{Example of two figures. (a) The first figure. (b) The second figure}
\label{fig_subfig}
\end{figure*}
%
\end{document}

相关内容