How to create two lstlisting environments, each of which has its own counter?
If I use for example
\lstnewenvironment{algorithm}[2]{
\renewcommand\lstlistingname{Algorithm}
\lstset{ ... }
} {}
\lstnewenvironment{program}[2]{
\renewcommand\lstlistingname{Program}
\lstset{ ... }
} {}
And then
\begin{algorithm}{Algorithm caption}{alg-label}
...
\end{algorithm}
\begin{program}{Program caption}{prg-label}
...
\end{program}
Then they will share the counter, that is, the result will look, for example, in
Algorithm 1.1
...
Program 1.2
...
I would like the count to be independent for different listing environments.
I also use the caption package to create a good caption. I have tried a lot, but have not achieved anything. The only way I found that indicates how to change the counter / file extension is \ DeclareCaptionType [fileext = alg] {algorithm}, but the problem is that this command already defines the new environment, so I donβt know how to use this along with a new list environment and subtitle package. I use, for example, the following settings:
\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox[cmyk]{0.43, 0.35, 0.35,0.01}{\parbox{\textwidth}{\hspace{15pt}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white, singlelinecheck=false, margin=0pt, font={bf,footnotesize}}