3

I would like to have a hyperlink to my examples created with expex

The use of \label and \ref produces the correct number, but the it links to the whole subsection and not to the example.

\documentclass[12pt]{scrbook}
\title{Untitled Document}
\author{Your Name}
\date{\today}

\usepackage{classicthesis}
\usepackage{expex, hyperref}
\usepackage{lipsum}


\begin{document}
\maketitle

\section{Section example}
\subsection{Subsection example}
\lipsum[1-3]
\ex This is an example \label{example1} \xe

The example (\ref{example1}) has the correct number, but it links to the whole subsection

\end{document}

Ideally, I would like to use the \label and \ref commands. The problem does not seem to depend on the usage of classicthesis. But I include this information since it may create some incompatibilities with your answer.

EDIT: A nice workaround is introducing a phantom section:

\newcommand{\plabel}{\phantomsection\label}

This does the job, and it does not require a lot of coding. But if you think that this might create some problems somehow, please let me know. Or if you know how to actually anchor to the expex example...

Help
  • 31
  • 1
    Welcome to TeX.SE! \phantomsection seems to be safe, see https://tex.stackexchange.com/questions/63895/click-to-go-to-an-anchored-line. You could also use \hypertarget but then the generated link is to the bottom of the line (see https://tex.stackexchange.com/questions/212161/adjust-jump-location-of-hypertargets) and it requires some extra code to actually show the example number in the link. – Marijn Apr 18 '19 at 13:40
  • @Marijn Thank you! I will use \phantomsection then – Help Apr 19 '19 at 08:00

0 Answers0