I have some code that looks like

\section*{Problem 1}

   \item Hello
   \item \label{problem-2b} Yes
   \item \cref{problem-2b} Welp

I want the reference to appear as

problem 1a) 

as a refference. How can I include the name of the previous section into the reference? I already have the exercise number as a counter.

For a "MWE" of my actual problem see below


\usepackage{etoolbox} %Neccecary for ifthenelse







 \NewDocumentCommand{\Oppgave}{s o}{   %
    {\normalfont\IfBooleanTF{#1}{Alternativ \Roman{alternative}~}{}}%
                \IfNoValueTF{#2}{}{\normalfont\normalsize (#2~poeng)}}%
   \addcontentsline{toc}{section}{Oppgave~\arabic{prob}} \refstepcounter{alfa} 



  \begin{enumerate}[ref={\alph{alfa}},topsep =1.2em,label=\textbf{\alph{alfa})},labelsep=1.5em,itemsep=0.7cm]



    linktoc=all,            % Link all the things in the toc
    colorlinks=true,        % false: boxed links; true: colored links
    linkcolor=black,          % color of internal links (change box color with linkbordercolor)

\usepackage[norsk, nameinlink, noabbrev]{cleveref}





\Oppgave[4] % Oppgave 1

    \item Prob 1

    \item \label{prob1b} Prob 2

    \item \cref{prob1b} Prob 3

  • 2
    Why are you using \section*? Change the section format to use "Problem" so that you have access to the regular section counter. – Alan Munn May 26 '19 at 15:53
  • Your first code example is rather incomplete while your second one is not very minimal. This is why I basically just answered the question title. Could you make a true MWE that will be helpful to others finding this question? – schtandard Aug 3 '19 at 11:34

You can do that by redefining \p@enumi.




\section{Some Section}

   \item Hello
   \item \label{some-item} Yes
   \item Bye

Look at item~\ref{some-item}


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.