使用 float 包的 subfloat 命令调整标题位置

使用 float 包的 subfloat 命令调整标题位置

我有一些代码以前在其他机器上可以正常工作,但目前我遇到了子浮点标题的问题:它们出现在图像旁边(左侧),而不是下方。这是一个简单的例子:

\documentclass[a4paper,twoside,12pt]{memoir}
\usepackage{graphicx}
\usepackage{float}
%\usepackage{subfig}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\subfloat[subcap 1]{\includegraphics[width=0.48\linewidth]{example-image-a}}
\subfloat[subcap 2]{\includegraphics[width=0.48\linewidth]{example-image-b}}
\caption{caption}
\end{figure}
\end{document}

结果如下:

subcaption_bug

我设法使用 subcaption 包获得了我想要的结果,其语法如下:

\begin{figure}
\centering
\begin{subfigure}{0.48\linewidth}
    \includegraphics[width=\linewidth]{example-image-a}
    \caption{subcap 1}
\end{subfigure}
\end{figure}

使用 subfig 时,它按预期工作。但我有一个非常大的文档,其中包含特定于 subcaption 的其他命令。如果可以的话,我不想改变一切...我对所有不同的 subfloat 包感到困惑。我只找到有关 subfig 或 subcaption 的信息。

我能做些什么?

谢谢!

答案1

请注意,该subfigure软件包已被弃用,其后继subfig软件包最后一次更新是在 2005 年。

因此,我建议您只使用该包的首选语法subcaption

\documentclass[a4paper,twoside,12pt]{memoir}
\usepackage{graphicx}
\usepackage{float}
%\usepackage{subfig}
\usepackage{subcaption}

\begin{document}
\begin{figure}
\centering
\subcaptionbox{subcap 1}{\includegraphics[width=0.48\linewidth]{example-image-a}}
\subcaptionbox{subcap 2}{\includegraphics[width=0.48\linewidth]{example-image-b}}
\caption{caption}
\end{figure}
\end{document}

在此处输入图片描述

相关内容