我怎样才能将两个子图居中对齐,并像这样对齐两个图的标题 (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}