Используйте \refstepcounter
вместо \stepcounter
.Это устанавливает, что будет использовать команда \label
, и переопределит thefpcounter
с помощью \renewcommand{\thefpcounter}{\arabic{fpcounter}}
.Это дает
Кроме того, предусмотрены некоторые другие параметры в зависимости от того, как вы хотите пометить пользовательскую среду.
\documentclass{book}
\newcounter{fpcounter}
%\renewcommand{\thefpcounter}{\thechapter.\arabic{fpcounter}}
%\renewcommand{\thefpcounter}{\thesection.\arabic{fpcounter}}
\renewcommand{\thefpcounter}{\arabic{fpcounter}}
\newenvironment{fp}[2]{%
\refstepcounter{fpcounter}%
\label{#1}%
\noindent\textbf{Problem~\thefpcounter}%
}%
{}%
\begin{document}
\chapter{Lorem}
\section{Ipsum}
\begin{fp}{fp:A}{}
content of environment 1
\end{fp}
\begin{fp}{fp:B}{}
content of environment 2
\end{fp}
\medskip\noindent
As shown in Problem~\ref{fp:A}, and Problem~\ref{fp:B}...
\end{document}