插入子图

插入子图

我正在尝试按照以下示例使用环境子图插入嵌套图形http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Subfloats

我添加了以下额外的包: \usepackage{subfigure}\usepackage{caption}\usepackage{subcaption}

这是我的 MWE:

\begin{figure}
    \begin{subfigure}%[b]{0.5\textwidth}
            \centering
            \includegraphics[width=\textwidth]{SR4000}
            \caption{SwissRanger by MESA}
            \label{fig:SRl}
    \end{subfigure}%
     %add desired spacing between images, e. g. ~, \quad, \qquad etc.
      %(or a blank line to force the subfigure onto a new line)
    \begin{subfigure}%[b]{0.5\textwidth}
            \centering
            \includegraphics[width=\textwidth]{D-Imager}
            \caption{D-Imager by Panasonic}
            \label{fig:D-Imager}
    \end{subfigure}
    \caption{TOF depth cameras}\label{fig:TOF}
\end{figure}

但我收到以下错误

! Use of \@subfloat doesn't match its definition. \reserved@c
->\@subfloat {
                          sub\@captype }[\@empty {\@empty }][{\@empty }] 
l.64                 \centering

这里的第 64 行是:

\includegraphics[width=\textwidth]{SR4000}

答案1

不要同时使用subfiguresubcaption。另外,subfigure已过时。较新的是subfig

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
    \begin{subfigure}[b]{0.5\textwidth}            
            \includegraphics[width=\textwidth]{example-image-a}
            \caption{SwissRanger by MESA}
            \label{fig:SRl}
    \end{subfigure}%
     %add desired spacing between images, e. g. ~, \quad, \qquad etc.
      %(or a blank line to force the subfigure onto a new line)
    \begin{subfigure}[b]{0.5\textwidth}
            \centering
            \includegraphics[width=\textwidth]{example-image-b}
            \caption{D-Imager by Panasonic}
            \label{fig:D-Imager}
    \end{subfigure}
    \caption{TOF depth cameras}\label{fig:TOF}
\end{figure}
\end{document}

在此处输入图片描述

相关内容