I'd like to generate "labels" to use at the beginning and at the end of an environment. Unfortunately the value of the counter is modified between the start and the end of the environment:
Any idea how I could avoid that issue?
\documentclass[a4paper,12pt]{article}
\newcounter{nextMarkId}
\newenvironment{subproof}{\thenextMarkId\stepcounter{nextMarkId}}{\thenextMarkId}
\begin{document}
\begin{subproof}
\begin{subproof}
blabla
\end{subproof}
\end{subproof}
I'd like to have: 0 1 blabla 1 0
\end{document}
EDIT
The proposed answer does not work because I want the label of each environment to be unique:
\documentclass[a4paper,12pt]{article}
\newcounter{nextMarkId}
\newenvironment{subproof}
{\thenextMarkId\stepcounter{nextMarkId}}
{\addtocounter{nextMarkId}{-1}\thenextMarkId}
\begin{document}
\begin{subproof}
\begin{subproof}
blabla
\end{subproof}
\begin{subproof}
blabla
\end{subproof}
\end{subproof}
I'd like to have: 0 1 blabla 1 2 blabla 2 0
\end{document}
I was thinking to use some sort of stack... but it seems quite ugly.
subproof
environments always start with 0?subproof
environment should have a different label (or maybe I should call it an identifier). Basically I just want to assign a different identifier to each environment to be able to address them individually later.