4

I want that each item on an enumerate list has a different hyperlink. Like this:

\documentclass{beamer}
\newcommand{\myitem}[2]{\item[\hyperlink{#2}{#1.\arabic{enumi}}]}

\begin{document}
   \begin{frame}
      \begin{enumerate}
         \myitem{1}{destination1} text 1
         \myitem{1}{destination2} text 2
      \end{enumerate}
   \end{frame}
\end{document}

the result should be:

1.1 text
1.2 text
...

However this does not wok and i get 1.0 for every number. How do I solve this?

2
  • 3
    You should add \refstepcounter{enumi} before \item in your new command \myitem. What is your purpose with this (creating a manual table of something...?)?
    – Ludovic C.
    Nov 17 '13 at 14:54
  • 1
    Where do the \hyperlinks point to? Do you have any \hypertarget in your document? Nov 17 '13 at 15:07
4

I am not sure I understood well your problem but here is what I got:

  1. You want to get hyperlinks from the number of the items pointing to some given destination elsewhere in the presentation (set via \hypertarget{label}{text}).
  2. You want the numbers to be automatically displayed for the items.
  3. (I have added this feature but I don't know if you are interested in it) You want to get the numbers of the items to be X.Y where Y is the Yth item of the current list and X is the Xth list you have in your document.

This led me to this MWE

\documentclass{beamer}

\newcounter{totenum}
\setcounter{totenum}{0}
\let\Oldenumerate\enumerate
\def\enumerate{\refstepcounter{totenum}\Oldenumerate}
\newcommand{\myitem}[1]{\refstepcounter{enumi}\item[\hyperlink{#1}{\arabic{totenum}.\arabic{enumi}}]}

\begin{document}
   \begin{frame}
      \begin{enumerate}
         \myitem{destination1} text 1
         \myitem{destination2} text 2
      \end{enumerate}

      \begin{enumerate}
         \myitem{destination3} text 3
         \myitem{destination4} text 4
      \end{enumerate}
   \end{frame}

   \begin{frame}
      \hypertarget{destination1}{The first item is pointing here.}
    \end{frame}

\end{document}

For this output (only the first frame):

Output

2
  • yes, this is it. I wasn't aware of the refstepcounter command. Sorry for the noob question
    – Richard S
    Nov 17 '13 at 16:42
  • @karlkoeller Haha, I don't know, but I am used to it! ;-)
    – Ludovic C.
    Nov 17 '13 at 18:06

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.