子标题包不工作

子标题包不工作

我正在使用 miktex 并更新所有软件包,我正在尝试使用subcaption下面文档中的示例

\documentclass[10pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}

\begin{figure}
    \centering
    \begin{subcaptionblock}{.2\textwidth}
        \centering
        \includegraphics{cat}
        \caption{A cat}\label{cat}
    \end{subcaptionblock}%
    \begin{subcaptionblock}{.2\textwidth}
        \centering
        \includegraphics{elephant}
        \caption{An elephant}\label{elephant}
    \end{subcaptionblock}%
    \caption{Two animals}\label{animals}
\end{figure}

\end{document}

我得到的是

在此处输入图片描述

怎么了?

答案1

\documentclass[10pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}

\begin{figure}
    \centering
    \begin{subcaptionblock}{.2\textwidth}
        \centering
        \includegraphics[width=.9\linewidth]{example-image-a}
        \caption{A cat}\label{cat}
    \end{subcaptionblock}%
    \begin{subcaptionblock}{.2\textwidth}
        \centering
        \includegraphics[width=.9\linewidth]{example-image-b}
        \caption{An elephant}\label{elephant}
    \end{subcaptionblock}%
    \caption{Two animals}\label{animals}
\end{figure}

\end{document}

在此处输入图片描述

相关内容