I'm trying to refer to the name of an amsthm theorem* environment using cleveref's namecref command.
However
\documentclass{article}
\usepackage{amsthm}
\usepackage{cleveref}
\newtheorem*{note}{Note}
\begin{document}
\section{Test}
\begin{note}\label{myNote}
Lorem ipsum...
\end{note}
In the previous \lcnamecref{myNote}...
\end{document}
yields
In the previous section...
rather than
In the previous note...
as the last line. Is there any way to change this behaviour?
Any help would be much appreciated.

\newtheorem*defines an unnumbered theorem environment, so it does not call\refstepcounterand label data is not set, thus\labelhappens to get whatever was set last, in this case, the section. In theory, you could set the\@currentcounterfor this, but it would be a stretch, and other reference data would not be meaningful for that label. You could use\label[note]{myNote}. But the same problem arises, if you forget and try to use\cref{myNote}you get "weird" results (a "note" reference, but the number will come from the section...). – gusbrs Mar 21 '24 at 20:49\labelwith the most recently incremented LaTeX counter. As you've defined thenoteenvironment not to receive a number, no counter is incremented when\begin{note}is executed. LaTeX therefore has no choice but to associatemyNotewith the the most recently incremented counter, which happens to be thesectioncounter; it's also why\lcnamerefgenerates "section" rather than "note". You ask, 'Is there any way to change this behaviour?' Answer: Start generaiting numberednoteenvironments. – Mico Mar 21 '24 at 20:53\label[note]{myNote}probably best fits my current use case; I don't want to number this particular environment, but wanted the below sentence to change were I to use, for instance, "Remark" instead of "Note". Since the label is right next to the environment, I'm sure I'll remember to update that also were I to change the environment. – Dave Mar 21 '24 at 21:13\label[note]{myNote}has some pitfalls. Bad use of label/ref automation, I'd say. If the reference is "right next to the environment", just write "in the previous note"... Better be explicit about something which is manual, than to pretend it is "automatic" and let it bite you on the slightest deviation from this particular use... But, of course, if you want, you can. To each their own. ;-) – gusbrs Mar 21 '24 at 21:22