图表引用数量

图表引用数量

我使用在本节中列举数字

\renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}

但是,当我使用对子图的引用时,得到的不是 1.1 (a),而是 1(a)。我该如何修复它?

工作示例

\documentclass{article}
\usepackage{amsmath}
\usepackage{subfigure}
\usepackage{graphicx}
\usepackage{caption}
\renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}

\makeatletter
\renewcommand{\thesection}{\arabic{section}.}
\renewcommand{\thesubsection}{\thesection\arabic{subsection}.}

\renewcommand{\section}{%
    \@startsection
        {section}{1}{0mm}
    {\baselineskip}
    {\baselineskip}
     {\fontsize{14}{14}\centering\bfseries\MakeUppercase}%       
   }
   \makeatother

\begin{document}
    \section{a}
    \begin{figure}[h] \label{fig:1} \centering
        \subfigure[]{\label{fig:11}
            \includegraphics[width=60mm]{1.png}}%
        \subfigure[]{\label{fig:12}
            \includegraphics[width=60mm]{2.png}}

        \caption{11 and 12}.
    \end{figure}
    \section{b}
        \ref{fig:11}
\end{document}

答案1

不要使用过时的subfigure软件包,你应该使用subfig或者subcaption;这是使用的代码subfig

\documentclass{article}
\usepackage{amsmath}
\usepackage{subfig}
\usepackage[demo]{graphicx}
\usepackage{caption}

\renewcommand{\thesection}{\arabic{section}.}
\renewcommand{\thesubsection}{\thesection\arabic{subsection}.}
\renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}

\makeatletter
\renewcommand{\section}{%
    \@startsection
        {section}{1}{0mm}
    {\baselineskip}
    {\baselineskip}
     {\fontsize{14}{14}\centering\bfseries\MakeUppercase}%       
   }
%subsection
\renewcommand{\subsection}{%
    \@startsection
    {subsection}{1}{0mm}
   {\baselineskip}
   {\baselineskip}
   {\fontsize{14}{14}\centering\bfseries\MakeUppercase}%
   }
\makeatother

\begin{document}

\section{a}
\begin{figure}[h] 
\centering
\subfloat[]{\label{fig:11}%
  \includegraphics[width=60mm]{1.png}}\ %
\subfloat[]{\label{fig:12}%
  \includegraphics[width=60mm]{2.png}}
\caption{11 and 12}
\label{fig:1} 
\end{figure}

\ref{fig:11} or \ref{fig:1}\subref{fig:11}

\end{document}

在此处输入图片描述

附注:\thefigure当新的部分开始时,重新定义不会重置计数器;如果您想重置计数器,可以使用

\@addtoreset{figure}{section}

内部\makeatletter,,\makeatother

\numberwithin{figure}{section}

amsmath包裹中,或

\counterwithin{figure}{section}

来自chngcntr包。还请注意,在浮动环境中,\label必须始终出现 \caption(在您的代码中\label是在之前\caption)。

如果由于某种原因您需要坚持使用 subfigure 包,那么您可以重新定义\thesubfigure\p@subfigure\@thesubfigure

\documentclass{article}
\usepackage{amsmath}
\usepackage{subfigure}
\usepackage[demo]{graphicx}
\usepackage{caption}

\renewcommand{\thesection}{\arabic{section}.}
\renewcommand{\thesubsection}{\thesection\arabic{subsection}.}
\renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}
\renewcommand{\thesubfigure}{\thefigure(\alph{subfigure})}
\makeatletter
\renewcommand{\p@subfigure}{}
\renewcommand{\@thesubfigure}{(\alph{subfigure})\hskip\subfiglabelskip}
\makeatother

\makeatletter
\renewcommand{\section}{%
    \@startsection
        {section}{1}{0mm}
    {\baselineskip}
    {\baselineskip}
     {\fontsize{14}{14}\centering\bfseries\MakeUppercase}%       
   }
%subsection
\renewcommand{\subsection}{%
    \@startsection
    {subsection}{1}{0mm}
   {\baselineskip}
   {\baselineskip}
   {\fontsize{14}{14}\centering\bfseries\MakeUppercase}%
   }
\makeatother

\begin{document}

\section{a}
\begin{figure}[h] 
\centering
\subfigure[]{\label{fig:11}%
  \includegraphics[width=60mm]{1.png}}\ %
\subfigure[]{\label{fig:12}%
  \includegraphics[width=60mm]{2.png}}
\caption{11 and 12}
\label{fig:1} 
\end{figure}

\ref{fig:11}

\end{document}

在此处输入图片描述

相关内容