How do I reset the counters for the steps and diagrams after each new proposition in my environment code?
\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}
\tkzDefPointOnLinepos=0.5\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}
Thanks
\newcounter) – David Carlisle Nov 26 '23 at 14:14\\as intext\\see https://tex.stackexchange.com/questions/334246/what-does-the-phrase-underfull-hbox-badness-10000-in-paragraph-actually-mea/334249#334249 – David Carlisle Nov 26 '23 at 15:32\usepackage{etoolbox} \AtBeginEnvironment{proposition}{\setcounter{CountDiag}{0}} worked for me
– Paul A Nov 26 '23 at 18:21propositionenvironment yourself, you can just add the reset code to the environment definition (just before\begin{center}) instead of patching it using etoolbox. – Willie Wong Nov 27 '23 at 04:34