2

I use a "description" environment and want to refer to certain items by name (which works fine). But I also want, that when a reader clicks on the resulting hyperlink that one jumps directly to the item then, not to the chapter, in which the description appears. Is this somehow possible?

Here is a MWE, which shows the problem - when clicking on the nameref, the PDF reader jumps to the beginning of the chapter:

\documentclass{scrreprt}

\usepackage{hyperref}
\usepackage{lipsum}


\begin{document}

\chapter{First sec}

\lipsum
\begin{description}
    \item [My first item\label{it:one}]
    This is my first item
\end{description}
\lipsum

Here I want to refer to my \nameref{it:one} and jump to it, when I click on it.

\end{document}

Can anybody assist me here?

Thanks

matse

  • 1
    Discription items does not have anchors that hyperref can grab on to try using \phantomsection\label(it:one} – daleif Jan 14 at 10:24
5

Description items (like itemize items) does not produce an anchor that hyperref can grab and point towards. Thus \label will use the nearest anchor, which is this case is from the \chapter command.

Solution: add \phantomsection before \label, this creates an anonymous anchor for hyperref to grab and point towards.

| improve this answer | |
  • This is great, thank you so much! – mathse Jan 14 at 12:20

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.