5

I'm lost in the maze of customization options in the cleveref package. The MWE says what I'm trying to do, and my best attempt so far.

I'm running TeXLive 2013, compiling with latexmk -pdf MWE.tex

Note: I don't need a more sophisticated package than memoir's extensions to enumerate, unless that helps solve the problem.

\documentclass{memoir}
\usepackage{hyperref}
\usepackage{cleveref}
\setsecnumdepth{subsubsection}

\begin{document}
\mainmatter
\chapter{one}
\label{chap:one}
\section{uno}
\label{sec:uno}
\subsection{ein}
\label{subsec:ein}

\begin{enumerate}[(a)]
\item
aaa
\item
\label[subsection]{enum:bbb}
bbb
\end{enumerate}

\subsection{zwei}

What I want is a cross reference that looks like ``section 1.1.1(b)''

But \verb|\cref{enum:bbb}| gives ``\cref{enum:bbb}''

\end{document}

Note: the comments and answer that suggest changing enumerate to subsubsection don't address the fact that I want the cross reference formatted differently from the section number in the document - as shown in the MWE, the numbering within the document should be just "(b)" but the reference should be "1.1.1(b)".

3
  • why don't you use \subsubsection{aaa} instead of enumerate environment.
    – ddas
    Jul 29 '16 at 18:48
  • @ddas In general there might be several enumerate environments within one subsection. There are very few cross-references to enumerated items, so I'm not bothered (so far!) about the possibility of ambiguous cross references. If I used \subsubsection I would still want the subsubsection numbered "(b)", and the reference to be "1.1.1(b)".
    – alephzero
    Jul 29 '16 at 18:55
  • If you use \subsubsection then you would get the reference as "section 1.1.1.2". As there are very few cross-reference, is there a big deference between "1.1.1(b)" and "section 1.1.1.2". Oh yes! I think @Robert has solved your problem..
    – ddas
    Jul 29 '16 at 19:07
4

Perhaps using the enumitem package with shortlabels and the ref=.... option key is a by-pass solution.

\documentclass{memoir}
\usepackage[shortlabels]{enumitem}
\usepackage{hyperref}
\usepackage{cleveref}
\setsecnumdepth{subsubsection}

\begin{document}
\mainmatter
\chapter{one}
\label{chap:one}
\section{uno}
\label{sec:uno}
\subsection{ein}
\label{subsec:ein}

\begin{enumerate}[(a),ref={\thesubsection(\alph*)}]
\item
  aaa \label{foo}
\item 
  \label[subsection]{enum:bbb}
  bbb
\end{enumerate}


\subsection{zwei}

What I want is a cross reference that looks like ``section 1.1.1(b)''

But \verb|\cref{enum:bbb}| gives ``\cref{enum:bbb}''

\end{document}

enter image description here

6
  • Please note that this will provide a wrong reference type for the regular foo etc. label then!
    – user31729
    Jul 29 '16 at 19:24
  • Can you add an example showing what you mean by "this will provide a wrong reference type for the regular foo etc. label"?
    – alephzero
    Jul 29 '16 at 19:31
  • @alephzero: Give \cref{foo} a try ;-)
    – user31729
    Jul 29 '16 at 19:33
  • "Give \cref{foo} a try" - I can probably live with that.
    – alephzero
    Jul 29 '16 at 19:46
  • @ChristianHupfer I think \cref{foo} works just fine no?
    – touhami
    Jul 29 '16 at 20:04
1

Using in the preamble:

\renewcommand{\thesubsubsection}{\thesubsection.\alph{subsubsection}}

with

\subsubsection{aaa}
%       \item
        aaa
\subsubsection{bbb}
        \label[subsection]{enum:bbb}
        bbb
%   \end{enumerate}

you get more or less what you want.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.