In my memoir document, all the subsections are unnumbered but are listed in the TOC. Is there some way to exploit cleveref (and hyperref) so as to cross-reference subsections that's more direct than the following?
\documentclass[12pt]{memoir}
\setsecnumdepth{subsection}
\settocdepth{subsection}
\setlength{\cftsubsectionindent}{5.25em}
\usepackage{lipsum}
\usepackage[colorlinks=true,linkcolor=red]{hyperref}
\usepackage[noabbrev,capitalize]{cleveref}
\crefname{subsection}{subsection}{subsection} % not used?
\Crefname{subsection}{Subsection}{Subsection}
\crefname{page}{page}{page}
\begin{document}
\tableofcontents
\chapter{The Chapter}
\subsection*{A particular situation}%
\label{subsec:particular}
\addcontentsline{toc}{subsection}{\nameref{subsec:particular}}
\lipsum[1]
\newpage
\subsection*{Another subsection}
\label{subsec:another}
\addcontentsline{toc}{subsection}{\nameref{subsec:another}}
See subsection~``\nameref*{subsec:particular}'' (\cpageref{subsec:particular}).
\noindent See subsection~``\nameref{subsec:particular}'' (\cpageref{subsec:particular}).
\end{document}
From the output:
Of course I can define a macro to do the \subsection*{...}\label{...}\addcontentsline... creation, and another to do the cross-referencing:
\documentclass[12pt]{memoir}
\setsecnumdepth{subsection}
\settocdepth{subsection}
\setlength{\cftsubsectionindent}{5.25em}
\usepackage{lipsum}
\usepackage[colorlinks=true,linkcolor=red]{hyperref}
\usepackage[noabbrev,capitalize]{cleveref}
\crefname{subsection}{subsection}{subsection} % not used?
\Crefname{subsection}{Subsection}{Subsection}
\crefname{page}{page}{page}
\newcommand{\subsec}[2]{%
\subsection*{#1}\label{subsec:#2}%
\addcontentsline{toc}{subsection}{\nameref{subsec:#2}}%
}
\usepackage{suffix}
\newcommand{\subsecref}[1]{%
subsection~``\nameref{subsec:#1}'' (\cpageref{subsec:#1})%
}
\WithSuffix\newcommand\subsecref*[1]{%
subsection~``\nameref*{subsec:#1}'' (\cpageref{subsec:#1})%
}
\begin{document}
\tableofcontents
\chapter{The Chapter}
\section{This stuff}\label{sec:stuff}
\subsec{A particular situation}{particular}
\lipsum[1]
\newpage
\subsec{Another subsection}{another}
See \subsecref{another}.
\noindent See \subsecref*{another}.
\end{document}
(The output will be the same as before.)
Is there no way to use cleveref, or otherwise, to automatically include "subsection" in the cross-reference (just as a \cref would do for a section)?





\subsection*{foo}\label[subsection]{subsec:foo}? But as there is no counter involved,\labelis pretty useless – Dec 27 '16 at 17:42\labeldoes allow cross-referencing. But I'd like LaTeX to "know" somehow that I'm referencing a subsection! – murray Dec 27 '16 at 17:50\labelneeds a counter information, however, you don't use numbered subsections. – Dec 27 '16 at 17:53