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?

  • 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
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

| improve this answer | |
  • 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

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.