I am trying to refer to a newenvironment
using cref
from the cleveref
package. Here is a MWE that demonstrates what I am trying to do.
\documentclass{article}
\usepackage{cleveref}
% define a newenvironment
\newcounter{projectCounter}
\setcounter{projectCounter}{0}
\newenvironment{project}[1]{\par\addvspace{1\baselineskip minus
20pt}\refstepcounter{projectCounter}{\bf\large Project
\arabic{projectCounter}: #1}\newline}{\par\addvspace{1\baselineskip minus 20pt}}
% define another newenvironment
\newcounter{subprojectCounter}
\setcounter{subprojectCounter}{0}
\newenvironment{subproject}[1]{\par\addvspace{1\baselineskip minus
20pt}\refstepcounter{subprojectCounter}{\bf\large Sub-project
\arabic{projectCounter}.\arabic{subprojectCounter}: #1}\newline}{\par\addvspace{1\baselineskip minus 20pt}}
% define a nested new environment
\newenvironment{projectStack}{\begin{project}\begin{subproject}}{\end{subproject}\end{project}}
% give names to the cref calls.
\crefname{project}{ project }{ projects }
\Crefname{project}{ Project }{ Projects }
\crefname{subproject}{ sub-project }{ sub-projects }
\Crefname{subproject}{ Sub-project }{ Sub-projects }
\begin{document}
This is a document that talks about sub-projects within projects.
\begin{project}{A}
Some information related to the project.
% begin a sub-project
\begin{subproject}{AA}
Some information related to the subproject.
\label{subproj:AA}
\end{subproject}
% begin another sub-project
\begin{subproject}{BB}
Some information related to the subproject.
\label{subproj:BB}
\end{subproject}
% begin a sub-project
\begin{subproject}{CC}
Some information related to the subproject.
\label{subproj:CC}
\end{subproject}
\label{proj:A}
\end{project}
Now let me try to refer to the projects, like so, \cref{proj:A}, and to
the subprojects, like so, \cref{subproj:AA,subproj:BB,subproj:CC}.
\end{document}
Here, I define the project
and subproject
newenvironment
s, and then try to refer to them using the cleveref
cref
function. This however does not seem to work, even though I have used the crefname
and the Crefname
functions.
Any help in resolving this issue would be very helpful.
Best Answer
\crefname
and the like should refer to a counter, not to an environment, so you should sayHere's a complete example, with some corrections to your macros.