[Tex/LaTex] Label a word or sentence

cross-referencinghyperreflabels

Is it possible to refer to a word in a sentence?

Example: Hi, I love\label{Word: Love} learning so I ask a lot of questions.

I would like to refer to the word "love" in the above sentence. For instance:

"I `ref{Word: Love}` you" would then read "I love you" but with "love" being clickable etc.

Is this possible?

(I know there are some related question here, but they are too complicated and different from the present one. I believe I have a simple and to the point question. )

Best Answer

You have somehow to mark the word you want to refer to:

\documentclass{article}
\usepackage[a6paper]{geometry}
\usepackage[colorlinks]{hyperref}

\makeatletter
\newcommand{\setword}[2]{%
  \phantomsection
  #1\def\@currentlabel{\unexpanded{#1}}\label{#2}%
}
\makeatother

\begin{document}

Some text just to see where the link will point to

Hi, I \setword{l\'ove}{Word:Love} learning so I ask a lot of questions.

\newpage

"I \ref{Word:Love} you"

\end{document}

Note the usage of the accent in order to show that it works even with special characters.

enter image description here

Related Question