Latex Numberwithin が最初の図では機能しない

Latex Numberwithin が最初の図では機能しない

私は大学の研究室用の文書を書こうとしており、これが私のコードです。

\section{Impuls- und Spungantwort für die drei Tiefpässe}    


 \begin{figure} [h!]
\centering
\includegraphics[width = \textwidth]{../durchfuehrung/lc_puls_flach.png} 
\caption{Anregung des LC-Tiefpasses (flach) mit einem Puls}
\label{LC Flach Puls}
\numberwithin{figure}{section}
\end{figure}


\begin{figure} [h!]
\centering
\includegraphics[width = \textwidth]{../durchfuehrung/lc_puls_steil.png} 
 \caption{Anregung des LC-Tiefpasses (steil) mit einem Puls}
\label{LC Steil Puls}
\numberwithin{figure}{section}
 \end{figure} \newpage

生成されたPDFファイルでは、図の番号は

2.1

そして

2.1.2

番号は2.1.1そして2.1.2問題が見つかりません。

これは私のメインの tex ファイルです。

\input{header}

\usepackage{chngcntr}
\usepackage{float}
\usepackage{color}
\usepackage{nameref}
\usepackage{graphicx}
\renewcommand{\chapterheadstartvskip}{\vspace{0pt}}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
pdfborder={0 0 0}
}
\numberwithin{figure} {section}

\begin{document}

\frontmatter
\include{kapitel/titelseite_Standard}
\tableofcontents

\mainmatter

\input{kapitel/vorbereitung}
\chapter{Durchführung und Auswertung}
\input{kapitel/LV_4_2_1}
\input{kapitel/LV_4_2_2}
\input{kapitel/LV_4_2_3}

%\include{kapitel/nuetzliches}
%\include{kapitel/blindtext}

%\bibliography{biblio/biblio}
\listoffigures
\bigskip
\begingroup
\let\clearpage\relax
\listoftables
\endgroup

答え1

をタップして\section\subsection数字カウンターの動作をリセットします。

ここに画像の説明を入力してください

\documentclass{article}

\usepackage{chngcntr,lipsum}

\let\oldsection\section
\let\oldsubsection\subsection
\renewcommand{\section}{\counterwithin{figure}{section}\oldsection}
\renewcommand{\subsection}{\counterwithin{figure}{subsection}\oldsubsection}

\begin{document}

\listoffigures

\section{A section}\lipsum[1]
\begin{figure}\caption{A caption}\end{figure}% 1.1
\begin{figure}\caption{A caption}\end{figure}% 1.2
\subsection{A subsection}\lipsum[2]
\begin{figure}\caption{A caption}\end{figure}% 1.1.1
\begin{figure}\caption{A caption}\end{figure}% 1.1.2
\subsection{A subsection}\lipsum[3]
\begin{figure}\caption{A caption}\end{figure}% 1.2.1
\begin{figure}\caption{A caption}\end{figure}% 1.2.2

\section{A section}\lipsum[1]
\begin{figure}\caption{A caption}\end{figure}% 2.1
\begin{figure}\caption{A caption}\end{figure}% 2.2
\subsection{A subsection}\lipsum[2]
\begin{figure}\caption{A caption}\end{figure}% 2.1.1
\begin{figure}\caption{A caption}\end{figure}% 2.1.2
\subsection{A subsection}\lipsum[3]
\begin{figure}\caption{A caption}\end{figure}% 2.2.1
\begin{figure}\caption{A caption}\end{figure}% 2.2.2

\end{document}

答え2

\counterrwithinすべての図で使用する代わりに、前文で使用します。

\documentclass{article}
\usepackage{geometry}
\geometry{legalpaper, margin=2in}

\usepackage{float}
\usepackage{color}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{chngcntr}

\counterwithin{figure}{subsection}

\begin{document}

\input{file1.tex}
\section{section01}
\input{file1.tex}
\input{file1.tex}

\end{document}

そしてfile1.tex:

\subsection{Smiles}    

\begin{figure} [h!]
\centering
\includegraphics[width = 0.1\textwidth]{smile.png} 
\caption{Smile:)}
\label{smile01}
\end{figure}

\begin{figure} [h!]
\centering
\includegraphics[width = 0.1\textwidth]{smile.png} 
\caption{Another smile}
\label{smile02}
\end{figure} 

結果の数字は0.1.1、0.1.2、1.1.1、1.1.2、1.2.1、1.2.2と番号が付けられます。

結果

[1]図、表、その他の文書要素の連続番号と章/セクションごとの番号付け

関連情報