2

Is it possible to link a word to the meaning at the end of file with cleveref?

Heres a MWE of my code:

\documentclass[12pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{cleveref}
\begin{document}
    Today I ran like a \label{cheetah}cheetah and it was amazing to feel the wind.

    \pagebreak

    \cref{cheetah}: is a large cat of the subfamily Felinae that occurs in North, Southern and East Africa, and a few localities in Iran. It inhabits a variety of mostly arid habitats like dry forests, scrub forests, and savannahs.
\end{document}

I wish the name cheetah in the sentence could be a link to the meaning at the end of the document and when I called \cref{cheetah} it showed only the name cheetah and not a number.

  • 1
    I think this is exactly what packages like gloassaries-extra are meant to do. It's their nature and would not require any extra manual work. You can define entries, then use them within in the text body. Together with hyperref, they will turn into links. These take you to a glossary, where many features are available, like a long explanation and a list of page numbers where the term was used. – Hans Lollo Mar 7 at 10:10
  • I'll take a look on that package. Thanks. – Levy Mar 7 at 12:36
3

There's good news and bad news. The bad news is that you cannot use \label and \cref to achieve your cross-referencing goal. This is because, given your setup LaTeX cannot meaningfully associate \label with a recently-incremented counter variable.

But there's also good news! You can fully achieve your typesetting goal by using the \hyperlink and \hypertarget macros of the hyperref package. Both \hyperlink and \hypertarget are macros which take two arguments. The first must be the same -- cheetah_def in the example below. The second is free-format -- cheetah and \textbf{Cheetah}, respectively, in the example below.

\documentclass{article}
\usepackage{hyperref}
\begin{document}

Today I ran like a \hyperlink{cheetah_def}{cheetah} and 
it was amazing to feel the wind.

\pagebreak

\noindent
\hypertarget{cheetah_def}{\textbf{Cheetah}}: A large cat 
of the subfamily Felinae that occurs in North, Southern 
and East Africa, and a few localities in Iran. It inhabits 
a variety of mostly arid habitats such as dry forests, 
scrub forests, and savannahs.
\end{document}
  • 2
    Thank you! It was what I needed. – Levy Mar 6 at 22:57

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.