I have the following self defined counter and command:
\documentclass{article} \newcounter{usecase}[section] \newcommand{\usecasenumber}{\arabic{usecase} \stepcounter{usecase} \newcommand{\usecase}[9]{ \begin{tabular}{| p{4cm} | p{8cm} |} \hline Anwendungsfall-Nummer & U-\usecasenumber \\ \hline Hauptakteur & #1 \\ \hline Andere Akteure & #2 \\ \hline Beschreibung & #3 \\ \hline Vorbedingung & #4 \\ \hline Nachbedingung & #5 \\ \hline Ausführung & #6 \\ \hline Alternativen & #7 \\ \hline Ausnahmen & #8 \\ \hline Benutzte Anwendungsfälle & #9 \\ \hline \end{tabular} } \begin{document} \usecase{1}{2}{3}{4}{5}{6}{7}{8}{9} \end{document} I now want an environment named usecase that does the exact same thing my newcommand does plus adding another line to the table with the name that one should be able to give the usecase environment. The environment should be able to automatically increase the counter and I want to be able to add labels to the usecase environment (just like it is possible in figure or table). When I reference such a label with \ref I want the reference to be the number of the environment given by the counter usecase.
I am not sure how to realize that or if it is even possible. I would start with something like this but I don't know how to proceed from there on to achieve the desired behaviour.
\newenvironment{usecase}[1]{\refstepcounter{usecase}}{ % TODO } It would be really appreciated if someone could help me out here. :)

\refstepcounterworks in a command as well. If a caption is needed, this is something different, of course