章节图数

章节图数

我需要按章节编号的图表:

我正在使用这个,但有时它会重复计数

\usepackage{chngcntr}
\counterwithin{figure}{chapter}
\counterwithin{table}{chapter}

例子:

chapter1
  figure 1.1
  figure 1.2
  figure 1.3
chapter2
  figure 2.1
 section 2.1
  figure 2.2
  figure 2.3
chapter3
  figure 3.1
  figure 3.2
 section 3.1
  figure 3.3

例子:

     \documentclass{report}
\usepackage{float}
\usepackage{chngcntr}
\counterwithin{figure}{section}

\begin{document}
\chapter{}
\section{section 1.1}

\begin{figure}[H]
\centering
\rule{1cm}{1cm}% placeholder for graphic
\caption{A figure}
\end{figure}

\begin{figure}[H]
\centering
\rule{1cm}{1cm}% placeholder for graphic
\caption{A figure}
\end{figure}

\section{section 1.2}

\begin{figure}[H]
\centering
\rule{1cm}{1cm}% placeholder for graphic
\caption{A figure}
\end{figure}



\chapter{}
\section{section 2.1}

\begin{figure}[H]
\centering
\rule{1cm}{1cm}% placeholder for graphic
\caption{A figure}
\end{figure}

\end{document}

这是屏幕截图: 在此处输入图片描述

答案1

  • report当需要章节时使用类。
  • 删除一些包(不需要获取输出)。
  • 不要在章节和章节中包含数字(这些是由 latex 自动创建的)

    \documentclass{report}
    
    \usepackage{float}
    
    \begin{document}
    
    \chapter{ } %if you want a name write it as \chapter{name}
    
    
    
    \begin{figure}[H]
    \centering
        \rule{1cm}{1cm}% placeholder for graphic
    \caption{A figure}
    \end{figure}
    
    \section{}
    
    \begin{figure}[H]
    \centering
    \rule{1cm}{1cm}% placeholder for graphic
     \caption{A figure}
    \end{figure}
    
    \section{ }
    
    \begin{figure}[H]
    \centering
    \rule{1cm}{1cm}% placeholder for graphic
    \caption{A figure}
    \end{figure}
    
     \end{document}
    

相关内容