3

I want to customize the text that appears when I do a \cref{}, so for example, I want to make a link to section 0.1 but I want the text to say 'Summary' not section 0.1. I had this part working with the following line at the top of my document:

\crefformat{section}{\textbf{#2Summary#3}}

and then when I call the reference I use:

\cref{sec:CogSysParadigm}

And it shows up as Summary (but with a red box around it). Which is perfect. My problem is that I can't get the same thing to work for an item. I tried 'item', itemize item, subitem, etc. Example of what I tried:

\crefformat{item}{#2ToC#3} % so this would have a ToC as the text 

and then I am using \cref like:

\cref{itm:CogSysParadigm} % but it gives me item 1(d)ii instead
2
  • Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Werner Jul 19 '13 at 5:00
  • 3
    Probably \crefformat{enumi}{#2ToC#3} solves the problem? – karlkoeller Jul 19 '13 at 5:30
4

I don't know why you need to modify the format of the references in this way, but I think that changing

\crefformat{item}{#2ToC#3}

to

\crefformat{enumi}{#2ToC#3}

is what you need.

For example, the following MWE

\documentclass{article}
\usepackage{hyperref}
\usepackage{cleveref}

\crefformat{enumi}{#2ToC#3}
\crefformat{section}{\textbf{#2Summary#3}}

\begin{document}

\section{introduction}\label{sec:CogSysParadigm}

\begin{enumerate}
  \item
  \begin{enumerate}
    \item 1.1
    \item 1.2
    \item 1.3
    \item
    \begin{enumerate}
      \item 1.4.1
      \item 1.4.2\label{itm:CogSysParadigm}
    \end{enumerate}
  \end{enumerate}
  \item 2
\end{enumerate}

In the \cref{sec:CogSysParadigm} I want to point out the \cref{itm:CogSysParadigm}.

\end{document}

produces:

enter image description here

Note that the first argument of \crefformat must be a counter and enumi, enumii and enumiii are the counters used by the enumerate environment for the first three levels.

Also note that this solution works at any level inside the enumerate environment. If you want it to work only at the third level you have to change enumi to enumiii.

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.