Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How do you hyperlink items without manually encoding the text of the hyperlink?

Suppose I want to number some items

\begin{enumerate}
\item blah
\item blah blah
\item blah blah blah

and I want each number to be a hyperlink. Say Item 1, Item 2, Item 3.

I tried

\begin{enumerate}[\hyperlink{Item 1}{Item 1}]

like I would normally do when not hyperlinking; it didn't work.

EDIT: What I really want to do is to label some questions with Q.1, Q.2, Q.3, ... and have these hyperlinked to answers A.1, A.2, A.3, ..., respectively. Is there a way for the items to be hyperlinked automatically and still be itemized automatically? I.e. the closer I got to the is to get every item hyperlinked but every item has the same number, e.g. Q.1, Q.1, ...

share|improve this question
    
Hyperlinks point somewhere. Where do you want these hyperlinks to point to? If you're just talking about reformatting the way the enumeration is listed, then both the enumerate and enumitem (the latter is preferred) will help. Please clarify. –  Werner Apr 5 '12 at 16:39
    
For instance I want to make a list of questions which are linked to some answers. Do I need to encode each link in the list manually? or is there some sleek way to do it. just as we can use \begin{enumerate}[1] to itemize the list with numbers. –  latexnoob Apr 5 '12 at 16:44
    
And thank you @Werner by the way for editing my lousy question. I don't know how to do the gray-box thing. –  latexnoob Apr 5 '12 at 16:45
1  
have a look at best-way-to-part-answers-from-solutions it seems very relevant –  cmhughes Apr 5 '12 at 17:38
    
@latexnoob: You simply indent code blocks by four spaces. You can also mark it and press CTRL+K. Inline code is marked using backticks: `code` –  Martin Scharrer Apr 5 '12 at 18:43
add comment

1 Answer 1

You wrote in a later comment: "For instance I want to make a list of questions which are linked to some answers". This can be achieved with the usual \label-\ref device and the optional argument to \item.

In the example below the answers are in the default enumerate environment. However, questions use the references to the answers instead of the default labels. Hyperref makes them clickable (try this!)

\documentclass{article}
\usepackage{hyperref}
\pagestyle{empty}
\begin{document}
Questions
\begin{enumerate}
\item[\ref{item:earth}.] What is the diameter of Earth?
\item[\ref{item:dwarfs}.] How many dwarfs were there in
  \emph{Sleeping Beauty?}
\end{enumerate}

\bigskip

Answers
\begin{enumerate}
\item 6400\,km\label{item:earth}
\item Seven\label{item:dwarfs}
\end{enumerate}

\end{document}

enter image description here

[For extra credit: find all the errors in the answers]

share|improve this answer
    
This is quite a manual (and delicate) approach- the answers package provides a much more robust method- see the linked question above –  cmhughes Apr 5 '12 at 17:59
    
@cmhughes Surely. For serious work one should use a specialized package. For one-time quick hack it is easier to write it than to find a package and learn how to use it. –  Boris Apr 5 '12 at 18:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.