为什么小页面的标题中没有显示图号?

为什么小页面的标题中没有显示图号?

我在 minipages 中包含了一系列图片(使用 \captionof 来添加标题),但不幸的是,标题根本没有显示图片编号。有人能帮我吗?代码和图片如下。谢谢

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{titlepic}
\usepackage{amsmath}
\usepackage{enumitem}% http://ctan.org/pkg/enumerate
\usepackage{rotating} 
\usepackage{float}
\usepackage{multirow}
\usepackage[margin=0.5in]{geometry}
\usepackage{titling}


\begin{document}
\SweaveOpts{concordance=TRUE}

\section{Disability}\label{sect:Disability}

\begin{minipage}{.5\linewidth}
    \centering
  \includegraphics[width=1\textwidth]{../figures/DisED.pdf}
  \captionof{}{Percentage of Population with a Disability (Both Sexes)}
  \label{fig:test1}
\end{minipage}%
\begin{minipage}{.5\linewidth}
  \centering
  \includegraphics[width=1\textwidth]{../figures/DisEDFemale.pdf}
  \captionof{}{Percentage of Population with a Disability (Female)}
  \label{fig:test2}
\end{minipage}

\begin{minipage}{.5\linewidth}
  \centering
  \includegraphics[width=1\textwidth]{../figures/DisEDMale.pdf}
  \captionof{}{Percentage of Population with a Disability (Male)}
  \label{fig:test2}
\end{minipage}
\pagebreak

\end{document}

在此处输入图片描述

答案1

你的例子根本没有定义\captionof,但如果例子固定为

\documentclass{article}

\usepackage{capt-of}

\begin{document}


\section{Disability}\label{sect:Disability}

\begin{minipage}{.5\linewidth}
    \centering
%  \includegraphics[width=1\textwidth]{../figures/DisED.pdf}
  \captionof{}{Percentage of Population with a Disability (Both Sexes)}
  \label{fig:test1}
\end{minipage}%


\end{document}

然后会产生错误

! LaTeX Error: No counter '' defined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.13   \captionof{}
                   {Percentage of Population with a Disability (Both Sexes)}
? 

任何错误 pdf 仅是一种调试辅助工具,并不旨在可用。

错误消息突出显示了空参数,而该参数应该是figure

\documentclass{article}

\usepackage{capt-of}

\begin{document}


\section{Disability}\label{sect:Disability}

\begin{minipage}{.5\linewidth}
    \centering
%  \includegraphics[width=1\textwidth]{../figures/DisED.pdf}
  \captionof{figure}{Percentage of Population with a Disability (Both Sexes)}
  \label{fig:test1}
\end{minipage}%


\end{document}

在此处输入图片描述

答案2

全部figure环境中:

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{titlepic}
\usepackage{amsmath}
\usepackage{enumitem}% http://ctan.org/pkg/enumerate
\usepackage{rotating} 
\usepackage{float}
\usepackage{multirow}
\usepackage[margin=0.5in]{geometry}
\usepackage{titling}


\begin{document}
    
\section{Disability}\label{sect:Disability}

\begin{figure}[!htb]
    \begin{minipage}[b]{.49\linewidth}
    \includegraphics[width=\textwidth]{../figures/DisED.pdf}%
    \end{minipage}\hfill
    \begin{minipage}[b]{.49\linewidth}
    \includegraphics[width=\textwidth]{../figures/DisEDFemale.pdf}
    \end{minipage}
    
    \vspace{-\medskipamount}
    \begin{minipage}[t]{.49\linewidth}
       \caption{Percentage of Population with a Disability (Both Sexes)}\label{fig:test1}
    \end{minipage}\hfill
    \begin{minipage}[t]{.49\linewidth}
        \caption{Percentage of Population with a Disability (Female)}\label{fig:test2}
    \end{minipage}
    
    \begin{minipage}{.5\linewidth}
    \includegraphics[width=\textwidth]{../figures/DisEDMale.pdf}
    \caption{Percentage of Population with a Disability (Male)}\label{fig:test3}
    \end{minipage}
\end{figure}
    
\end{document}

在此处输入图片描述

答案3

在环境文档中插入带有图形的迷你页面figure并使用标准\caption命令:

\documentclass{article}
\usepackage[margin=0.5in]{geometry}
\usepackage[demo]{graphicx}  % in real document remove option "demo"
\usepackage{caption}

\begin{document}

\section{Disability}
\label{sect:Disability}

\begin{figure}[htb]
\captionsetup{skip=1ex, belowskip=2ex}
\setkeys{Gin}{width=\linewidth}
    \begin{minipage}[b]{.48\linewidth}
\includegraphics{../figures/DisED.pdf}%
\caption{Percentage of Population with a Disability (Both Sexes)}\label{fig:test1}
    \end{minipage}\hfill
    \begin{minipage}[b]{.48\linewidth}
\includegraphics{../figures/DisEDFemale.pdf}
\caption{Percentage of Population with a Disability (Female)}\label{fig:test2}
    \end{minipage}

    \begin{minipage}{.48\linewidth}
\includegraphics{../figures/DisEDMale.pdf}
\caption{Percentage of Population with a Disability (Male)}\label{fig:test3}
    \end{minipage}
\end{figure}

\end{document}

在此处输入图片描述

相关内容