2

I have, for example, a section of a book with the label 'Bases'.

I want to create a hyperlink every time I type 'Bases' in my text without putting a command like ~\ref{}.

CarLaTeX
  • 62,716
Nali
  • 23

2 Answers2

3

Why don't simply use a new command?

\documentclass{article}
\usepackage{hyperref}
\usepackage{xspace}
\newcommand{\Bases}{Section~\ref{Bases}\xspace}

\begin{document}
    \section{Just for example}\label{Bases}
    This is the reference \Bases to the section.
    This is another reference \Bases.
\end{document}

The hyperlinks aren't shown in the image but there are in the .pdf:

enter image description here

If you use fancyref package it is better to put sec: before the reference name "Bases", see LaTeX/Labels and Cross-referencing for more info.

CarLaTeX
  • 62,716
1

This might be a simple way of doing it. Just add a command for each word. The \ behind the command in the text is just to make the following space character render as a space.

\documentclass{article}
\usepackage{hyperref}
\newcommand{\base}{\href{http://www.allyourbasearebelongtous.com}{base}}

\begin{document}
All your \base\ are belong to us!
\end{document} 

Example output:

All your base