2

I need to reference some items from an enumerate environment. I can do this by adding a label at the beginning of each \item (see MWE at the bottom). So far, so good.

Each item in the enumerate has a parenthesis (set through the (\arabic*) option) and I would like to keep it that way. However, this creates an issue when referencing the label: if I do so within a parenthetical in my text, I will have two consecutive opening or closing parentheses (see image at the end of the result). I find this undesirable.

Is there a way I can change this default behavior, but only for some cross-references? To be clear, I would prefer to keep the same format of the enumerate list (numbers within parentheses) and the format of the "normal" cross-reference (outside of a parenthetical); only a couple cross-references would have to be edited manually. In other words, I do not want to change the default reference behavior across the whole document. The desired result, in the example image below, would be:

I reference items: (1). But what if I use parentheses (for example, 2)?

(note the lack of double parentheses).

Is there a way to achieve this? I suppose I need to use the enumitem and cleveref packages (which I have loaded anyway), but I am open to all suggestions.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{enumitem}
\usepackage{cleveref}
\begin{document}
    This is a list:
    \begin{enumerate}[label=(\arabic*)]
        \item\label{item:apple} Apple
        \item\label{item:pear} Pear
        \item\label{item:orange} Orange
    \end{enumerate}
    I reference items: \ref{item:apple}. But what if I use parentheses (for example, \ref{item:pear})?
\end{document}

enter image description here

GioMott
  • 195

0 Answers0