在新环境中重置计数器

在新环境中重置计数器

如何在我的环境代码中每次提出新命题后重置步骤和图表的计数器?

\documentclass{book}

\usepackage{blindtext}
\usepackage{tikz}
\usepackage{tkz-euclide}

\newcommand{\AB}{0.75}   % A  and B added <<<<<<<<<<<<<<
\newcommand{\C}{1.5}    % C added <<<<<<<<<<<<<<
\newcommand{\AD}{0.75} % D added<<<<<<<<<<<<<<
\newcommand{\Asize}{0.25}   % Angle added <<<<<<<<<<<<<<

\newcommand{\AG}{1.5}


% Standard packages
\usepackage{
    float, 
    graphicx
}

% Set page margins
\usepackage[top=1.0in, bottom=1.0in, left=1.0in, right=1.0in].   {geometry}

\setlength{\marginparwidth}{0pt}

% Set nice page headers
\usepackage{fancyhdr}
\pagestyle{fancy}

% Paragraph style
\setlength{\parindent}{0em}
\setlength{\parskip}{1em}


% Proposition environment
\newenvironment{proposition}
   {\begin{center}\em}
   {\end{center}}

\newcounter{CountStep}
\newcounter{CountDiag}

\newenvironment{diagram}    %Where i think I need to change     something<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
{\stepcounter{CountStep}\stepcounter{CountDiag}\vspace*{10pt}     Step~\theCountStep\par
\begin{center}
\begin{tikzpicture}}
    {\end{tikzpicture}\vspace*{-5pt}\par Diagram~\theCountDiag
\end{center}}

\begin{document}

\chapter{Proposition 1-6}
\section{Proposition 6}
\begin{proposition}
    If two angles (B, C) of a triangle be equal, the sides (AC,     AB) opposite to them are also equal.
\end{proposition}
   
\begin{diagram}

\tkzDefPoints{-\AB/0/A,\AB/0/B,0/\C/C}

\tkzDrawPolygon(A,B,C)


\end{diagram}

text\\

\begin{diagram}

    \tkzDefPoints{-\AB/0/A,\AB/0/B,0/\C/C}
    
    \tkzDefPointOnLine[pos=0.7](A,C)\tkzGetPoint{D}

\tkzDrawPolygon(A,B,C)

 \end{diagram}

    \clearpage

\section{Proposition 7}

\begin{proposition}
text
\end{proposition}

\begin{center}
\begin{tabular}{ccc}
\begin{tikzpicture}
    \tkzDefPoints{-\AB/0/A,\AB/0/B,0/\C/C,1/\AD/D}

    \tkzDefPointOnLine[pos=0.5](B,C)\tkzGetPoint{E}

\tkzDrawPolygon(A,B,C)

\end{tikzpicture}
&
\begin{tikzpicture}
\tkzDefPoints{-\AB/0/A,\AB/0/B,0/\C/C,1/\AD/D}

\tkzDefPointOnLine[pos=0.5](B,C)\tkzGetPoint{E}

%\tkzDrawPolygon(A,B,C)

\end{tikzpicture}
&
\begin{tikzpicture}
\tkzDefPoints{-\AB/0/A,\AB/0/B,0/\C/C,1/\AD/D}

    \tkzDefPointOnLine[pos=0.5](B,C)\tkzGetPoint{E}

\tkzDrawPolygon(A,B,C)
\tkzDrawPolygon(A,B,D)


\end{tikzpicture}
\end{tabular}
\end{center}
text

\begin{diagram}

\tkzDefPoints{-\AB/0/A,\AB/0/B,0/\C/C,1/\AD/D}

    \tkzDefPointOnLine[pos=0.5](B,C)\tkzGetPoint{E}

\tkzDrawPolygon(A,B,C)
\tkzDrawPolygon(A,B,D)


\end{diagram}
text

\clearpage


\end{document}

谢谢

相关内容