1

I have this MWE:

\documentclass{article}
\usepackage{hyperref}
\usepackage{enumerate}

\begin{document}
\begin{enumerate}[\label=(X1)]
\item\label{i1} Hu
\item\label{i2} Pu
\end{enumerate}

Hello \ref{i1}.

\end{document}

In the PDF, I expected to see, "X1" as a hyperlink, but instead only "1" is coming:

How can I get "X1" automatically in the reference?

hola
  • 4,026
  • 3
  • 35
  • 72
  • 1
    As mentioned on Page 1 of the enumerate manual: \ref only produces the counter value, not the whole label. So I think it is not possible to acheive your goal using the enumerate package. An alternative is to use the enumitem package. – Ruixi Zhang Sep 25 '18 at 16:40
  • 2
    By the way, [\label=(X1)] only works by pure accident and you indeed fine warnings about Label `=' multiply defined – egreg Sep 25 '18 at 16:42

1 Answers1

3

Have a look at enumitem package!

\documentclass{article}
\usepackage{enumitem}
\usepackage{hyperref}

\begin{document}
    \begin{enumerate}[label=(X\arabic*), ref=X\arabic*]
        \item\label{i1} Hu
        \item\label{i2} Pu
    \end{enumerate}

    Hello \ref{i1}.

\end{document}

enter image description here

NBur
  • 4,326
  • 10
  • 27
  • 1
    Minor suggestion: hyperref after enumitem. See, e.g., this answer. – Ruixi Zhang Sep 25 '18 at 16:40
  • When I try, \usepackage{enumitem}, I get the error, Undefined control sequence. \end{itemize}. – hola Sep 25 '18 at 16:58
  • OK, I guess found the problem, \usepackage{paralist}. – hola Sep 25 '18 at 17:14
  • 2
    @pushpen.paul Yes, enumitem and paralist are incompatible. When using enumitem, to get paragraph-like lists, type something like \begin{enumerate}[wide] ... \end{enumerate}; to get inline lists, use the package option inline and then type something like \begin{enumerate*} ... \end{enumerate*}. – Ruixi Zhang Sep 25 '18 at 17:45